Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1 | /* |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/io.h> |
| 18 | #include <asm/unaligned.h> |
| 19 | |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 20 | #include "hw.h" |
Luis R. Rodriguez | cfe8cba | 2009-09-13 23:39:31 -0700 | [diff] [blame] | 21 | #include "rc.h" |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 22 | #include "initvals.h" |
| 23 | |
Luis R. Rodriguez | 4febf7b | 2008-12-23 15:58:48 -0800 | [diff] [blame] | 24 | #define ATH9K_CLOCK_RATE_CCK 22 |
| 25 | #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 |
| 26 | #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 27 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 28 | static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type); |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 29 | static void ath9k_hw_set_regs(struct ath_hw *ah, struct ath9k_channel *chan); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 30 | static u32 ath9k_hw_ini_fixup(struct ath_hw *ah, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 31 | struct ar5416_eeprom_def *pEepData, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 32 | u32 reg, u32 value); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 33 | |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 34 | MODULE_AUTHOR("Atheros Communications"); |
| 35 | MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards."); |
| 36 | MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards"); |
| 37 | MODULE_LICENSE("Dual BSD/GPL"); |
| 38 | |
| 39 | static int __init ath9k_init(void) |
| 40 | { |
| 41 | return 0; |
| 42 | } |
| 43 | module_init(ath9k_init); |
| 44 | |
| 45 | static void __exit ath9k_exit(void) |
| 46 | { |
| 47 | return; |
| 48 | } |
| 49 | module_exit(ath9k_exit); |
| 50 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 51 | /********************/ |
| 52 | /* Helper Functions */ |
| 53 | /********************/ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 54 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 55 | static u32 ath9k_hw_mac_usec(struct ath_hw *ah, u32 clks) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 56 | { |
Luis R. Rodriguez | b002a4a | 2009-09-13 00:03:27 -0700 | [diff] [blame] | 57 | struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 58 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 59 | if (!ah->curchan) /* should really check for CCK instead */ |
Luis R. Rodriguez | 4febf7b | 2008-12-23 15:58:48 -0800 | [diff] [blame] | 60 | return clks / ATH9K_CLOCK_RATE_CCK; |
| 61 | if (conf->channel->band == IEEE80211_BAND_2GHZ) |
| 62 | return clks / ATH9K_CLOCK_RATE_2GHZ_OFDM; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 63 | |
Luis R. Rodriguez | 4febf7b | 2008-12-23 15:58:48 -0800 | [diff] [blame] | 64 | return clks / ATH9K_CLOCK_RATE_5GHZ_OFDM; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 65 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 66 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 67 | static u32 ath9k_hw_mac_to_usec(struct ath_hw *ah, u32 clks) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 68 | { |
Luis R. Rodriguez | b002a4a | 2009-09-13 00:03:27 -0700 | [diff] [blame] | 69 | struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 70 | |
Luis R. Rodriguez | 4febf7b | 2008-12-23 15:58:48 -0800 | [diff] [blame] | 71 | if (conf_is_ht40(conf)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 72 | return ath9k_hw_mac_usec(ah, clks) / 2; |
| 73 | else |
| 74 | return ath9k_hw_mac_usec(ah, clks); |
| 75 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 76 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 77 | static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 78 | { |
Luis R. Rodriguez | b002a4a | 2009-09-13 00:03:27 -0700 | [diff] [blame] | 79 | struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 80 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 81 | if (!ah->curchan) /* should really check for CCK instead */ |
Luis R. Rodriguez | 4febf7b | 2008-12-23 15:58:48 -0800 | [diff] [blame] | 82 | return usecs *ATH9K_CLOCK_RATE_CCK; |
| 83 | if (conf->channel->band == IEEE80211_BAND_2GHZ) |
| 84 | return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM; |
| 85 | return usecs *ATH9K_CLOCK_RATE_5GHZ_OFDM; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 86 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 87 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 88 | static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 89 | { |
Luis R. Rodriguez | b002a4a | 2009-09-13 00:03:27 -0700 | [diff] [blame] | 90 | struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 91 | |
Luis R. Rodriguez | 4febf7b | 2008-12-23 15:58:48 -0800 | [diff] [blame] | 92 | if (conf_is_ht40(conf)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 93 | return ath9k_hw_mac_clks(ah, usecs) * 2; |
| 94 | else |
| 95 | return ath9k_hw_mac_clks(ah, usecs); |
| 96 | } |
| 97 | |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 98 | bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 99 | { |
| 100 | int i; |
| 101 | |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 102 | BUG_ON(timeout < AH_TIME_QUANTUM); |
| 103 | |
| 104 | for (i = 0; i < (timeout / AH_TIME_QUANTUM); i++) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 105 | if ((REG_READ(ah, reg) & mask) == val) |
| 106 | return true; |
| 107 | |
| 108 | udelay(AH_TIME_QUANTUM); |
| 109 | } |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 110 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 111 | ath_print(ath9k_hw_common(ah), ATH_DBG_ANY, |
| 112 | "timeout (%d us) on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n", |
| 113 | timeout, reg, REG_READ(ah, reg), mask, val); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 114 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 115 | return false; |
| 116 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 117 | EXPORT_SYMBOL(ath9k_hw_wait); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 118 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 119 | u32 ath9k_hw_reverse_bits(u32 val, u32 n) |
| 120 | { |
| 121 | u32 retval; |
| 122 | int i; |
| 123 | |
| 124 | for (i = 0, retval = 0; i < n; i++) { |
| 125 | retval = (retval << 1) | (val & 1); |
| 126 | val >>= 1; |
| 127 | } |
| 128 | return retval; |
| 129 | } |
| 130 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 131 | bool ath9k_get_channel_edges(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 132 | u16 flags, u16 *low, |
| 133 | u16 *high) |
| 134 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 135 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 136 | |
| 137 | if (flags & CHANNEL_5GHZ) { |
| 138 | *low = pCap->low_5ghz_chan; |
| 139 | *high = pCap->high_5ghz_chan; |
| 140 | return true; |
| 141 | } |
| 142 | if ((flags & CHANNEL_2GHZ)) { |
| 143 | *low = pCap->low_2ghz_chan; |
| 144 | *high = pCap->high_2ghz_chan; |
| 145 | return true; |
| 146 | } |
| 147 | return false; |
| 148 | } |
| 149 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 150 | u16 ath9k_hw_computetxtime(struct ath_hw *ah, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 151 | u8 phy, int kbps, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 152 | u32 frameLen, u16 rateix, |
| 153 | bool shortPreamble) |
| 154 | { |
| 155 | u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 156 | |
| 157 | if (kbps == 0) |
| 158 | return 0; |
| 159 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 160 | switch (phy) { |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 161 | case WLAN_RC_PHY_CCK: |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 162 | phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS; |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 163 | if (shortPreamble) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 164 | phyTime >>= 1; |
| 165 | numBits = frameLen << 3; |
| 166 | txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps); |
| 167 | break; |
Sujith | 46d14a5 | 2008-11-18 09:08:13 +0530 | [diff] [blame] | 168 | case WLAN_RC_PHY_OFDM: |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 169 | if (ah->curchan && IS_CHAN_QUARTER_RATE(ah->curchan)) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 170 | bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_QUARTER) / 1000; |
| 171 | numBits = OFDM_PLCP_BITS + (frameLen << 3); |
| 172 | numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol); |
| 173 | txTime = OFDM_SIFS_TIME_QUARTER |
| 174 | + OFDM_PREAMBLE_TIME_QUARTER |
| 175 | + (numSymbols * OFDM_SYMBOL_TIME_QUARTER); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 176 | } else if (ah->curchan && |
| 177 | IS_CHAN_HALF_RATE(ah->curchan)) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 178 | bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_HALF) / 1000; |
| 179 | numBits = OFDM_PLCP_BITS + (frameLen << 3); |
| 180 | numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol); |
| 181 | txTime = OFDM_SIFS_TIME_HALF + |
| 182 | OFDM_PREAMBLE_TIME_HALF |
| 183 | + (numSymbols * OFDM_SYMBOL_TIME_HALF); |
| 184 | } else { |
| 185 | bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME) / 1000; |
| 186 | numBits = OFDM_PLCP_BITS + (frameLen << 3); |
| 187 | numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol); |
| 188 | txTime = OFDM_SIFS_TIME + OFDM_PREAMBLE_TIME |
| 189 | + (numSymbols * OFDM_SYMBOL_TIME); |
| 190 | } |
| 191 | break; |
| 192 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 193 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 194 | "Unknown phy %u (rate ix %u)\n", phy, rateix); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 195 | txTime = 0; |
| 196 | break; |
| 197 | } |
| 198 | |
| 199 | return txTime; |
| 200 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 201 | EXPORT_SYMBOL(ath9k_hw_computetxtime); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 202 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 203 | void ath9k_hw_get_channel_centers(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 204 | struct ath9k_channel *chan, |
| 205 | struct chan_centers *centers) |
| 206 | { |
| 207 | int8_t extoff; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 208 | |
| 209 | if (!IS_CHAN_HT40(chan)) { |
| 210 | centers->ctl_center = centers->ext_center = |
| 211 | centers->synth_center = chan->channel; |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | if ((chan->chanmode == CHANNEL_A_HT40PLUS) || |
| 216 | (chan->chanmode == CHANNEL_G_HT40PLUS)) { |
| 217 | centers->synth_center = |
| 218 | chan->channel + HT40_CHANNEL_CENTER_SHIFT; |
| 219 | extoff = 1; |
| 220 | } else { |
| 221 | centers->synth_center = |
| 222 | chan->channel - HT40_CHANNEL_CENTER_SHIFT; |
| 223 | extoff = -1; |
| 224 | } |
| 225 | |
| 226 | centers->ctl_center = |
| 227 | centers->synth_center - (extoff * HT40_CHANNEL_CENTER_SHIFT); |
Luis R. Rodriguez | 6420014 | 2009-09-13 22:05:04 -0700 | [diff] [blame] | 228 | /* 25 MHz spacing is supported by hw but not on upper layers */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 229 | centers->ext_center = |
Luis R. Rodriguez | 6420014 | 2009-09-13 22:05:04 -0700 | [diff] [blame] | 230 | centers->synth_center + (extoff * HT40_CHANNEL_CENTER_SHIFT); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /******************/ |
| 234 | /* Chip Revisions */ |
| 235 | /******************/ |
| 236 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 237 | static void ath9k_hw_read_revisions(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 238 | { |
| 239 | u32 val; |
| 240 | |
| 241 | val = REG_READ(ah, AR_SREV) & AR_SREV_ID; |
| 242 | |
| 243 | if (val == 0xFF) { |
| 244 | val = REG_READ(ah, AR_SREV); |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 245 | ah->hw_version.macVersion = |
| 246 | (val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S; |
| 247 | ah->hw_version.macRev = MS(val, AR_SREV_REVISION2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 248 | ah->is_pciexpress = (val & AR_SREV_TYPE2_HOST_MODE) ? 0 : 1; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 249 | } else { |
| 250 | if (!AR_SREV_9100(ah)) |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 251 | ah->hw_version.macVersion = MS(val, AR_SREV_VERSION); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 252 | |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 253 | ah->hw_version.macRev = val & AR_SREV_REVISION; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 254 | |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 255 | if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 256 | ah->is_pciexpress = true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 257 | } |
| 258 | } |
| 259 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 260 | static int ath9k_hw_get_radiorev(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 261 | { |
| 262 | u32 val; |
| 263 | int i; |
| 264 | |
| 265 | REG_WRITE(ah, AR_PHY(0x36), 0x00007058); |
| 266 | |
| 267 | for (i = 0; i < 8; i++) |
| 268 | REG_WRITE(ah, AR_PHY(0x20), 0x00010000); |
| 269 | val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff; |
| 270 | val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4); |
| 271 | |
| 272 | return ath9k_hw_reverse_bits(val, 8); |
| 273 | } |
| 274 | |
| 275 | /************************************/ |
| 276 | /* HW Attach, Detach, Init Routines */ |
| 277 | /************************************/ |
| 278 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 279 | static void ath9k_hw_disablepcie(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 280 | { |
Sujith | feed029 | 2009-01-29 11:37:35 +0530 | [diff] [blame] | 281 | if (AR_SREV_9100(ah)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 282 | return; |
| 283 | |
| 284 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); |
| 285 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); |
| 286 | REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029); |
| 287 | REG_WRITE(ah, AR_PCIE_SERDES, 0x57160824); |
| 288 | REG_WRITE(ah, AR_PCIE_SERDES, 0x25980579); |
| 289 | REG_WRITE(ah, AR_PCIE_SERDES, 0x00000000); |
| 290 | REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); |
| 291 | REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); |
| 292 | REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007); |
| 293 | |
| 294 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); |
| 295 | } |
| 296 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 297 | static bool ath9k_hw_chip_test(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 298 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 299 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 300 | u32 regAddr[2] = { AR_STA_ID0, AR_PHY_BASE + (8 << 2) }; |
| 301 | u32 regHold[2]; |
| 302 | u32 patternData[4] = { 0x55555555, |
| 303 | 0xaaaaaaaa, |
| 304 | 0x66666666, |
| 305 | 0x99999999 }; |
| 306 | int i, j; |
| 307 | |
| 308 | for (i = 0; i < 2; i++) { |
| 309 | u32 addr = regAddr[i]; |
| 310 | u32 wrData, rdData; |
| 311 | |
| 312 | regHold[i] = REG_READ(ah, addr); |
| 313 | for (j = 0; j < 0x100; j++) { |
| 314 | wrData = (j << 16) | j; |
| 315 | REG_WRITE(ah, addr, wrData); |
| 316 | rdData = REG_READ(ah, addr); |
| 317 | if (rdData != wrData) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 318 | ath_print(common, ATH_DBG_FATAL, |
| 319 | "address test failed " |
| 320 | "addr: 0x%08x - wr:0x%08x != " |
| 321 | "rd:0x%08x\n", |
| 322 | addr, wrData, rdData); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 323 | return false; |
| 324 | } |
| 325 | } |
| 326 | for (j = 0; j < 4; j++) { |
| 327 | wrData = patternData[j]; |
| 328 | REG_WRITE(ah, addr, wrData); |
| 329 | rdData = REG_READ(ah, addr); |
| 330 | if (wrData != rdData) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 331 | ath_print(common, ATH_DBG_FATAL, |
| 332 | "address test failed " |
| 333 | "addr: 0x%08x - wr:0x%08x != " |
| 334 | "rd:0x%08x\n", |
| 335 | addr, wrData, rdData); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 336 | return false; |
| 337 | } |
| 338 | } |
| 339 | REG_WRITE(ah, regAddr[i], regHold[i]); |
| 340 | } |
| 341 | udelay(100); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 342 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 343 | return true; |
| 344 | } |
| 345 | |
Luis R. Rodriguez | b8b0f37 | 2009-08-03 12:24:43 -0700 | [diff] [blame] | 346 | static void ath9k_hw_init_config(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 347 | { |
| 348 | int i; |
| 349 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 350 | ah->config.dma_beacon_response_time = 2; |
| 351 | ah->config.sw_beacon_response_time = 10; |
| 352 | ah->config.additional_swba_backoff = 0; |
| 353 | ah->config.ack_6mb = 0x0; |
| 354 | ah->config.cwm_ignore_extcca = 0; |
| 355 | ah->config.pcie_powersave_enable = 0; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 356 | ah->config.pcie_clock_req = 0; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 357 | ah->config.pcie_waen = 0; |
| 358 | ah->config.analog_shiftreg = 1; |
| 359 | ah->config.ht_enable = 1; |
| 360 | ah->config.ofdm_trig_low = 200; |
| 361 | ah->config.ofdm_trig_high = 500; |
| 362 | ah->config.cck_trig_high = 200; |
| 363 | ah->config.cck_trig_low = 100; |
| 364 | ah->config.enable_ani = 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 365 | |
| 366 | for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 367 | ah->config.spurchans[i][0] = AR_NO_SPUR; |
| 368 | ah->config.spurchans[i][1] = AR_NO_SPUR; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 369 | } |
| 370 | |
Sujith | 0ce024c | 2009-12-14 14:57:00 +0530 | [diff] [blame^] | 371 | ah->config.rx_intr_mitigation = true; |
Luis R. Rodriguez | 6158425 | 2009-03-12 18:18:49 -0400 | [diff] [blame] | 372 | |
| 373 | /* |
| 374 | * We need this for PCI devices only (Cardbus, PCI, miniPCI) |
| 375 | * _and_ if on non-uniprocessor systems (Multiprocessor/HT). |
| 376 | * This means we use it for all AR5416 devices, and the few |
| 377 | * minor PCI AR9280 devices out there. |
| 378 | * |
| 379 | * Serialization is required because these devices do not handle |
| 380 | * well the case of two concurrent reads/writes due to the latency |
| 381 | * involved. During one read/write another read/write can be issued |
| 382 | * on another CPU while the previous read/write may still be working |
| 383 | * on our hardware, if we hit this case the hardware poops in a loop. |
| 384 | * We prevent this by serializing reads and writes. |
| 385 | * |
| 386 | * This issue is not present on PCI-Express devices or pre-AR5416 |
| 387 | * devices (legacy, 802.11abg). |
| 388 | */ |
| 389 | if (num_possible_cpus() > 1) |
David S. Miller | 2d6a5e9 | 2009-03-17 15:01:30 -0700 | [diff] [blame] | 390 | ah->config.serialize_regmode = SER_REG_MODE_AUTO; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 391 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 392 | EXPORT_SYMBOL(ath9k_hw_init); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 393 | |
Luis R. Rodriguez | 50aca25 | 2009-08-03 12:24:42 -0700 | [diff] [blame] | 394 | static void ath9k_hw_init_defaults(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 395 | { |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 396 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
| 397 | |
| 398 | regulatory->country_code = CTRY_DEFAULT; |
| 399 | regulatory->power_limit = MAX_RATE_POWER; |
| 400 | regulatory->tp_scale = ATH9K_TP_SCALE_MAX; |
| 401 | |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 402 | ah->hw_version.magic = AR5416_MAGIC; |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 403 | ah->hw_version.subvendorid = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 404 | |
| 405 | ah->ah_flags = 0; |
Luis R. Rodriguez | 8df5d1b | 2009-08-03 12:24:37 -0700 | [diff] [blame] | 406 | if (ah->hw_version.devid == AR5416_AR9100_DEVID) |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 407 | ah->hw_version.macVersion = AR_SREV_VERSION_9100; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 408 | if (!AR_SREV_9100(ah)) |
| 409 | ah->ah_flags = AH_USE_EEPROM; |
| 410 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 411 | ah->atim_window = 0; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 412 | ah->sta_id1_defaults = AR_STA_ID1_CRPT_MIC_ENABLE; |
| 413 | ah->beacon_interval = 100; |
| 414 | ah->enable_32kHz_clock = DONT_USE_32KHZ; |
| 415 | ah->slottime = (u32) -1; |
| 416 | ah->acktimeout = (u32) -1; |
| 417 | ah->ctstimeout = (u32) -1; |
| 418 | ah->globaltxtimeout = (u32) -1; |
Gabor Juhos | cbdec97 | 2009-07-24 17:27:22 +0200 | [diff] [blame] | 419 | ah->power_mode = ATH9K_PM_UNDEFINED; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 422 | static int ath9k_hw_rf_claim(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 423 | { |
| 424 | u32 val; |
| 425 | |
| 426 | REG_WRITE(ah, AR_PHY(0), 0x00000007); |
| 427 | |
| 428 | val = ath9k_hw_get_radiorev(ah); |
| 429 | switch (val & AR_RADIO_SREV_MAJOR) { |
| 430 | case 0: |
| 431 | val = AR_RAD5133_SREV_MAJOR; |
| 432 | break; |
| 433 | case AR_RAD5133_SREV_MAJOR: |
| 434 | case AR_RAD5122_SREV_MAJOR: |
| 435 | case AR_RAD2133_SREV_MAJOR: |
| 436 | case AR_RAD2122_SREV_MAJOR: |
| 437 | break; |
| 438 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 439 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 440 | "Radio Chip Rev 0x%02X not supported\n", |
| 441 | val & AR_RADIO_SREV_MAJOR); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 442 | return -EOPNOTSUPP; |
| 443 | } |
| 444 | |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 445 | ah->hw_version.analog5GhzRev = val; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 446 | |
| 447 | return 0; |
| 448 | } |
| 449 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 450 | static int ath9k_hw_init_macaddr(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 451 | { |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 452 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 453 | u32 sum; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 454 | int i; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 455 | u16 eeval; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 456 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 457 | sum = 0; |
| 458 | for (i = 0; i < 3; i++) { |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 459 | eeval = ah->eep_ops->get_eeprom(ah, AR_EEPROM_MAC(i)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 460 | sum += eeval; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 461 | common->macaddr[2 * i] = eeval >> 8; |
| 462 | common->macaddr[2 * i + 1] = eeval & 0xff; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 463 | } |
Sujith | d8baa93 | 2009-03-30 15:28:25 +0530 | [diff] [blame] | 464 | if (sum == 0 || sum == 0xffff * 3) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 465 | return -EADDRNOTAVAIL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 466 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 467 | return 0; |
| 468 | } |
| 469 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 470 | static void ath9k_hw_init_rxgain_ini(struct ath_hw *ah) |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 471 | { |
| 472 | u32 rxgain_type; |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 473 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 474 | if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= AR5416_EEP_MINOR_VER_17) { |
| 475 | rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE); |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 476 | |
| 477 | if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 478 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 479 | ar9280Modes_backoff_13db_rxgain_9280_2, |
| 480 | ARRAY_SIZE(ar9280Modes_backoff_13db_rxgain_9280_2), 6); |
| 481 | else if (rxgain_type == AR5416_EEP_RXGAIN_23DB_BACKOFF) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 482 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 483 | ar9280Modes_backoff_23db_rxgain_9280_2, |
| 484 | ARRAY_SIZE(ar9280Modes_backoff_23db_rxgain_9280_2), 6); |
| 485 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 486 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 487 | ar9280Modes_original_rxgain_9280_2, |
| 488 | ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 489 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 490 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 491 | ar9280Modes_original_rxgain_9280_2, |
| 492 | ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 493 | } |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 494 | } |
| 495 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 496 | static void ath9k_hw_init_txgain_ini(struct ath_hw *ah) |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 497 | { |
| 498 | u32 txgain_type; |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 499 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 500 | if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= AR5416_EEP_MINOR_VER_19) { |
| 501 | txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 502 | |
| 503 | if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 504 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 505 | ar9280Modes_high_power_tx_gain_9280_2, |
| 506 | ARRAY_SIZE(ar9280Modes_high_power_tx_gain_9280_2), 6); |
| 507 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 508 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 509 | ar9280Modes_original_tx_gain_9280_2, |
| 510 | ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 511 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 512 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 513 | ar9280Modes_original_tx_gain_9280_2, |
| 514 | ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 515 | } |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 516 | } |
| 517 | |
Luis R. Rodriguez | f637cfd | 2009-08-03 12:24:46 -0700 | [diff] [blame] | 518 | static int ath9k_hw_post_init(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 519 | { |
| 520 | int ecode; |
| 521 | |
Sujith | d8baa93 | 2009-03-30 15:28:25 +0530 | [diff] [blame] | 522 | if (!ath9k_hw_chip_test(ah)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 523 | return -ENODEV; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 524 | |
| 525 | ecode = ath9k_hw_rf_claim(ah); |
| 526 | if (ecode != 0) |
| 527 | return ecode; |
| 528 | |
Luis R. Rodriguez | f637cfd | 2009-08-03 12:24:46 -0700 | [diff] [blame] | 529 | ecode = ath9k_hw_eeprom_init(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 530 | if (ecode != 0) |
| 531 | return ecode; |
Sujith | 7d01b22 | 2009-03-13 08:55:55 +0530 | [diff] [blame] | 532 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 533 | ath_print(ath9k_hw_common(ah), ATH_DBG_CONFIG, |
| 534 | "Eeprom VER: %d, REV: %d\n", |
| 535 | ah->eep_ops->get_eeprom_ver(ah), |
| 536 | ah->eep_ops->get_eeprom_rev(ah)); |
Sujith | 7d01b22 | 2009-03-13 08:55:55 +0530 | [diff] [blame] | 537 | |
Luis R. Rodriguez | 574d6b1 | 2009-10-19 02:33:37 -0400 | [diff] [blame] | 538 | if (!AR_SREV_9280_10_OR_LATER(ah)) { |
| 539 | ecode = ath9k_hw_rf_alloc_ext_banks(ah); |
| 540 | if (ecode) { |
| 541 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 542 | "Failed allocating banks for " |
| 543 | "external radio\n"); |
| 544 | return ecode; |
| 545 | } |
| 546 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 547 | |
| 548 | if (!AR_SREV_9100(ah)) { |
| 549 | ath9k_hw_ani_setup(ah); |
Luis R. Rodriguez | f637cfd | 2009-08-03 12:24:46 -0700 | [diff] [blame] | 550 | ath9k_hw_ani_init(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 551 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 552 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 553 | return 0; |
| 554 | } |
| 555 | |
Luis R. Rodriguez | ee2bb46 | 2009-08-03 12:24:39 -0700 | [diff] [blame] | 556 | static bool ath9k_hw_devid_supported(u16 devid) |
| 557 | { |
| 558 | switch (devid) { |
| 559 | case AR5416_DEVID_PCI: |
| 560 | case AR5416_DEVID_PCIE: |
| 561 | case AR5416_AR9100_DEVID: |
| 562 | case AR9160_DEVID_PCI: |
| 563 | case AR9280_DEVID_PCI: |
| 564 | case AR9280_DEVID_PCIE: |
| 565 | case AR9285_DEVID_PCIE: |
| 566 | case AR5416_DEVID_AR9287_PCI: |
| 567 | case AR5416_DEVID_AR9287_PCIE: |
Luis R. Rodriguez | 7976b42 | 2009-09-23 23:07:02 -0400 | [diff] [blame] | 568 | case AR9271_USB: |
Luis R. Rodriguez | ee2bb46 | 2009-08-03 12:24:39 -0700 | [diff] [blame] | 569 | return true; |
| 570 | default: |
| 571 | break; |
| 572 | } |
| 573 | return false; |
| 574 | } |
| 575 | |
Luis R. Rodriguez | f9d4a66 | 2009-08-03 12:24:41 -0700 | [diff] [blame] | 576 | static bool ath9k_hw_macversion_supported(u32 macversion) |
| 577 | { |
| 578 | switch (macversion) { |
| 579 | case AR_SREV_VERSION_5416_PCI: |
| 580 | case AR_SREV_VERSION_5416_PCIE: |
| 581 | case AR_SREV_VERSION_9160: |
| 582 | case AR_SREV_VERSION_9100: |
| 583 | case AR_SREV_VERSION_9280: |
| 584 | case AR_SREV_VERSION_9285: |
| 585 | case AR_SREV_VERSION_9287: |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 586 | case AR_SREV_VERSION_9271: |
Luis R. Rodriguez | 7976b42 | 2009-09-23 23:07:02 -0400 | [diff] [blame] | 587 | return true; |
Luis R. Rodriguez | f9d4a66 | 2009-08-03 12:24:41 -0700 | [diff] [blame] | 588 | default: |
| 589 | break; |
| 590 | } |
| 591 | return false; |
| 592 | } |
| 593 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 594 | static void ath9k_hw_init_cal_settings(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 595 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 596 | if (AR_SREV_9160_10_OR_LATER(ah)) { |
| 597 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 598 | ah->iq_caldata.calData = &iq_cal_single_sample; |
| 599 | ah->adcgain_caldata.calData = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 600 | &adc_gain_cal_single_sample; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 601 | ah->adcdc_caldata.calData = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 602 | &adc_dc_cal_single_sample; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 603 | ah->adcdc_calinitdata.calData = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 604 | &adc_init_dc_cal; |
| 605 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 606 | ah->iq_caldata.calData = &iq_cal_multi_sample; |
| 607 | ah->adcgain_caldata.calData = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 608 | &adc_gain_cal_multi_sample; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 609 | ah->adcdc_caldata.calData = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 610 | &adc_dc_cal_multi_sample; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 611 | ah->adcdc_calinitdata.calData = |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 612 | &adc_init_dc_cal; |
| 613 | } |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 614 | ah->supp_cals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 615 | } |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 616 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 617 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 618 | static void ath9k_hw_init_mode_regs(struct ath_hw *ah) |
| 619 | { |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 620 | if (AR_SREV_9271(ah)) { |
Luis R. Rodriguez | 8564328 | 2009-10-19 02:33:33 -0400 | [diff] [blame] | 621 | INIT_INI_ARRAY(&ah->iniModes, ar9271Modes_9271, |
| 622 | ARRAY_SIZE(ar9271Modes_9271), 6); |
| 623 | INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, |
| 624 | ARRAY_SIZE(ar9271Common_9271), 2); |
| 625 | INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, |
| 626 | ar9271Modes_9271_1_0_only, |
| 627 | ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6); |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 628 | return; |
| 629 | } |
| 630 | |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 631 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
| 632 | INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1, |
| 633 | ARRAY_SIZE(ar9287Modes_9287_1_1), 6); |
| 634 | INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1, |
| 635 | ARRAY_SIZE(ar9287Common_9287_1_1), 2); |
| 636 | if (ah->config.pcie_clock_req) |
| 637 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 638 | ar9287PciePhy_clkreq_off_L1_9287_1_1, |
| 639 | ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_1), 2); |
| 640 | else |
| 641 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 642 | ar9287PciePhy_clkreq_always_on_L1_9287_1_1, |
| 643 | ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_1), |
| 644 | 2); |
| 645 | } else if (AR_SREV_9287_10_OR_LATER(ah)) { |
| 646 | INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_0, |
| 647 | ARRAY_SIZE(ar9287Modes_9287_1_0), 6); |
| 648 | INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_0, |
| 649 | ARRAY_SIZE(ar9287Common_9287_1_0), 2); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 650 | |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 651 | if (ah->config.pcie_clock_req) |
| 652 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 653 | ar9287PciePhy_clkreq_off_L1_9287_1_0, |
| 654 | ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_0), 2); |
| 655 | else |
| 656 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 657 | ar9287PciePhy_clkreq_always_on_L1_9287_1_0, |
| 658 | ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_0), |
| 659 | 2); |
| 660 | } else if (AR_SREV_9285_12_OR_LATER(ah)) { |
| 661 | |
Senthil Balasubramanian | 4e84516 | 2009-03-06 11:24:10 +0530 | [diff] [blame] | 662 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 663 | INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 664 | ARRAY_SIZE(ar9285Modes_9285_1_2), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 665 | INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 666 | ARRAY_SIZE(ar9285Common_9285_1_2), 2); |
| 667 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 668 | if (ah->config.pcie_clock_req) { |
| 669 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 670 | ar9285PciePhy_clkreq_off_L1_9285_1_2, |
| 671 | ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285_1_2), 2); |
| 672 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 673 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 674 | ar9285PciePhy_clkreq_always_on_L1_9285_1_2, |
| 675 | ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285_1_2), |
| 676 | 2); |
| 677 | } |
| 678 | } else if (AR_SREV_9285_10_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 679 | INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 680 | ARRAY_SIZE(ar9285Modes_9285), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 681 | INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 682 | ARRAY_SIZE(ar9285Common_9285), 2); |
| 683 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 684 | if (ah->config.pcie_clock_req) { |
| 685 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 686 | ar9285PciePhy_clkreq_off_L1_9285, |
| 687 | ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285), 2); |
| 688 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 689 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 690 | ar9285PciePhy_clkreq_always_on_L1_9285, |
| 691 | ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285), 2); |
| 692 | } |
| 693 | } else if (AR_SREV_9280_20_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 694 | INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 695 | ARRAY_SIZE(ar9280Modes_9280_2), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 696 | INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 697 | ARRAY_SIZE(ar9280Common_9280_2), 2); |
| 698 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 699 | if (ah->config.pcie_clock_req) { |
| 700 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 701 | ar9280PciePhy_clkreq_off_L1_9280, |
| 702 | ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280),2); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 703 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 704 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 705 | ar9280PciePhy_clkreq_always_on_L1_9280, |
| 706 | ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 707 | } |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 708 | INIT_INI_ARRAY(&ah->iniModesAdditional, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 709 | ar9280Modes_fast_clock_9280_2, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 710 | ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 711 | } else if (AR_SREV_9280_10_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 712 | INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 713 | ARRAY_SIZE(ar9280Modes_9280), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 714 | INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 715 | ARRAY_SIZE(ar9280Common_9280), 2); |
| 716 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 717 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 718 | ARRAY_SIZE(ar5416Modes_9160), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 719 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 720 | ARRAY_SIZE(ar5416Common_9160), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 721 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 722 | ARRAY_SIZE(ar5416Bank0_9160), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 723 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 724 | ARRAY_SIZE(ar5416BB_RfGain_9160), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 725 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 726 | ARRAY_SIZE(ar5416Bank1_9160), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 727 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 728 | ARRAY_SIZE(ar5416Bank2_9160), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 729 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 730 | ARRAY_SIZE(ar5416Bank3_9160), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 731 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 732 | ARRAY_SIZE(ar5416Bank6_9160), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 733 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 734 | ARRAY_SIZE(ar5416Bank6TPC_9160), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 735 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 736 | ARRAY_SIZE(ar5416Bank7_9160), 2); |
| 737 | if (AR_SREV_9160_11(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 738 | INIT_INI_ARRAY(&ah->iniAddac, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 739 | ar5416Addac_91601_1, |
| 740 | ARRAY_SIZE(ar5416Addac_91601_1), 2); |
| 741 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 742 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 743 | ARRAY_SIZE(ar5416Addac_9160), 2); |
| 744 | } |
| 745 | } else if (AR_SREV_9100_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 746 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 747 | ARRAY_SIZE(ar5416Modes_9100), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 748 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 749 | ARRAY_SIZE(ar5416Common_9100), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 750 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 751 | ARRAY_SIZE(ar5416Bank0_9100), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 752 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 753 | ARRAY_SIZE(ar5416BB_RfGain_9100), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 754 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 755 | ARRAY_SIZE(ar5416Bank1_9100), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 756 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 757 | ARRAY_SIZE(ar5416Bank2_9100), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 758 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 759 | ARRAY_SIZE(ar5416Bank3_9100), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 760 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 761 | ARRAY_SIZE(ar5416Bank6_9100), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 762 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 763 | ARRAY_SIZE(ar5416Bank6TPC_9100), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 764 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 765 | ARRAY_SIZE(ar5416Bank7_9100), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 766 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 767 | ARRAY_SIZE(ar5416Addac_9100), 2); |
| 768 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 769 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 770 | ARRAY_SIZE(ar5416Modes), 6); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 771 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 772 | ARRAY_SIZE(ar5416Common), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 773 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 774 | ARRAY_SIZE(ar5416Bank0), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 775 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 776 | ARRAY_SIZE(ar5416BB_RfGain), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 777 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 778 | ARRAY_SIZE(ar5416Bank1), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 779 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 780 | ARRAY_SIZE(ar5416Bank2), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 781 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 782 | ARRAY_SIZE(ar5416Bank3), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 783 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 784 | ARRAY_SIZE(ar5416Bank6), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 785 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 786 | ARRAY_SIZE(ar5416Bank6TPC), 3); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 787 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 788 | ARRAY_SIZE(ar5416Bank7), 2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 789 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 790 | ARRAY_SIZE(ar5416Addac), 2); |
| 791 | } |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 792 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 793 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 794 | static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah) |
| 795 | { |
Vivek Natarajan | b37fa87 | 2009-09-23 16:27:27 +0530 | [diff] [blame] | 796 | if (AR_SREV_9287_11_OR_LATER(ah)) |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 797 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 798 | ar9287Modes_rx_gain_9287_1_1, |
| 799 | ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 6); |
| 800 | else if (AR_SREV_9287_10(ah)) |
| 801 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 802 | ar9287Modes_rx_gain_9287_1_0, |
| 803 | ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_0), 6); |
| 804 | else if (AR_SREV_9280_20(ah)) |
| 805 | ath9k_hw_init_rxgain_ini(ah); |
| 806 | |
Vivek Natarajan | b37fa87 | 2009-09-23 16:27:27 +0530 | [diff] [blame] | 807 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 808 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 809 | ar9287Modes_tx_gain_9287_1_1, |
| 810 | ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 6); |
| 811 | } else if (AR_SREV_9287_10(ah)) { |
| 812 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 813 | ar9287Modes_tx_gain_9287_1_0, |
| 814 | ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_0), 6); |
| 815 | } else if (AR_SREV_9280_20(ah)) { |
| 816 | ath9k_hw_init_txgain_ini(ah); |
| 817 | } else if (AR_SREV_9285_12_OR_LATER(ah)) { |
Senthil Balasubramanian | 4e84516 | 2009-03-06 11:24:10 +0530 | [diff] [blame] | 818 | u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); |
| 819 | |
| 820 | /* txgain table */ |
| 821 | if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) { |
| 822 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 823 | ar9285Modes_high_power_tx_gain_9285_1_2, |
| 824 | ARRAY_SIZE(ar9285Modes_high_power_tx_gain_9285_1_2), 6); |
| 825 | } else { |
| 826 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 827 | ar9285Modes_original_tx_gain_9285_1_2, |
| 828 | ARRAY_SIZE(ar9285Modes_original_tx_gain_9285_1_2), 6); |
| 829 | } |
| 830 | |
| 831 | } |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 832 | } |
Senthil Balasubramanian | 4e84516 | 2009-03-06 11:24:10 +0530 | [diff] [blame] | 833 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 834 | static void ath9k_hw_init_11a_eeprom_fix(struct ath_hw *ah) |
| 835 | { |
| 836 | u32 i, j; |
Sujith | 06d0f06 | 2009-02-12 10:06:45 +0530 | [diff] [blame] | 837 | |
| 838 | if ((ah->hw_version.devid == AR9280_DEVID_PCI) && |
| 839 | test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) { |
| 840 | |
| 841 | /* EEPROM Fixup */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 842 | for (i = 0; i < ah->iniModes.ia_rows; i++) { |
| 843 | u32 reg = INI_RA(&ah->iniModes, i, 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 844 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 845 | for (j = 1; j < ah->iniModes.ia_columns; j++) { |
| 846 | u32 val = INI_RA(&ah->iniModes, i, j); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 847 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 848 | INI_RA(&ah->iniModes, i, j) = |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 849 | ath9k_hw_ini_fixup(ah, |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 850 | &ah->eeprom.def, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 851 | reg, val); |
| 852 | } |
| 853 | } |
| 854 | } |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 855 | } |
| 856 | |
Luis R. Rodriguez | f637cfd | 2009-08-03 12:24:46 -0700 | [diff] [blame] | 857 | int ath9k_hw_init(struct ath_hw *ah) |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 858 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 859 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 860 | int r = 0; |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 861 | |
Luis R. Rodriguez | 3ca3403 | 2009-09-23 23:07:01 -0400 | [diff] [blame] | 862 | if (!ath9k_hw_devid_supported(ah->hw_version.devid)) { |
| 863 | ath_print(common, ATH_DBG_FATAL, |
| 864 | "Unsupported device ID: 0x%0x\n", |
| 865 | ah->hw_version.devid); |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 866 | return -EOPNOTSUPP; |
Luis R. Rodriguez | 3ca3403 | 2009-09-23 23:07:01 -0400 | [diff] [blame] | 867 | } |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 868 | |
| 869 | ath9k_hw_init_defaults(ah); |
| 870 | ath9k_hw_init_config(ah); |
| 871 | |
| 872 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 873 | ath_print(common, ATH_DBG_FATAL, |
| 874 | "Couldn't reset chip\n"); |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 875 | return -EIO; |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 876 | } |
| 877 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 878 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 879 | ath_print(common, ATH_DBG_FATAL, "Couldn't wakeup chip\n"); |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 880 | return -EIO; |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) { |
| 884 | if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI || |
| 885 | (AR_SREV_9280(ah) && !ah->is_pciexpress)) { |
| 886 | ah->config.serialize_regmode = |
| 887 | SER_REG_MODE_ON; |
| 888 | } else { |
| 889 | ah->config.serialize_regmode = |
| 890 | SER_REG_MODE_OFF; |
| 891 | } |
| 892 | } |
| 893 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 894 | ath_print(common, ATH_DBG_RESET, "serialize_regmode is %d\n", |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 895 | ah->config.serialize_regmode); |
| 896 | |
Luis R. Rodriguez | f4709fd | 2009-11-24 21:37:57 -0500 | [diff] [blame] | 897 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) |
| 898 | ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD >> 1; |
| 899 | else |
| 900 | ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD; |
| 901 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 902 | if (!ath9k_hw_macversion_supported(ah->hw_version.macVersion)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 903 | ath_print(common, ATH_DBG_FATAL, |
| 904 | "Mac Chip Rev 0x%02x.%x is not supported by " |
| 905 | "this driver\n", ah->hw_version.macVersion, |
| 906 | ah->hw_version.macRev); |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 907 | return -EOPNOTSUPP; |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | if (AR_SREV_9100(ah)) { |
| 911 | ah->iq_caldata.calData = &iq_cal_multi_sample; |
| 912 | ah->supp_cals = IQ_MISMATCH_CAL; |
| 913 | ah->is_pciexpress = false; |
| 914 | } |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 915 | |
| 916 | if (AR_SREV_9271(ah)) |
| 917 | ah->is_pciexpress = false; |
| 918 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 919 | ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID); |
| 920 | |
| 921 | ath9k_hw_init_cal_settings(ah); |
| 922 | |
| 923 | ah->ani_function = ATH9K_ANI_ALL; |
Luis R. Rodriguez | e68a060 | 2009-10-19 02:33:41 -0400 | [diff] [blame] | 924 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 925 | ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL; |
Luis R. Rodriguez | e68a060 | 2009-10-19 02:33:41 -0400 | [diff] [blame] | 926 | ah->ath9k_hw_rf_set_freq = &ath9k_hw_ar9280_set_channel; |
Luis R. Rodriguez | ae478cf | 2009-10-19 02:33:43 -0400 | [diff] [blame] | 927 | ah->ath9k_hw_spur_mitigate_freq = &ath9k_hw_9280_spur_mitigate; |
| 928 | } else { |
Luis R. Rodriguez | e68a060 | 2009-10-19 02:33:41 -0400 | [diff] [blame] | 929 | ah->ath9k_hw_rf_set_freq = &ath9k_hw_set_channel; |
Luis R. Rodriguez | ae478cf | 2009-10-19 02:33:43 -0400 | [diff] [blame] | 930 | ah->ath9k_hw_spur_mitigate_freq = &ath9k_hw_spur_mitigate; |
| 931 | } |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 932 | |
| 933 | ath9k_hw_init_mode_regs(ah); |
| 934 | |
| 935 | if (ah->is_pciexpress) |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 936 | ath9k_hw_configpcipowersave(ah, 0, 0); |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 937 | else |
| 938 | ath9k_hw_disablepcie(ah); |
| 939 | |
Sujith | 193cd45 | 2009-09-18 15:04:07 +0530 | [diff] [blame] | 940 | /* Support for Japan ch.14 (2484) spread */ |
| 941 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
| 942 | INIT_INI_ARRAY(&ah->iniCckfirNormal, |
| 943 | ar9287Common_normal_cck_fir_coeff_92871_1, |
| 944 | ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_92871_1), 2); |
| 945 | INIT_INI_ARRAY(&ah->iniCckfirJapan2484, |
| 946 | ar9287Common_japan_2484_cck_fir_coeff_92871_1, |
| 947 | ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_92871_1), 2); |
| 948 | } |
| 949 | |
Luis R. Rodriguez | f637cfd | 2009-08-03 12:24:46 -0700 | [diff] [blame] | 950 | r = ath9k_hw_post_init(ah); |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 951 | if (r) |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 952 | return r; |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 953 | |
| 954 | ath9k_hw_init_mode_gain_regs(ah); |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 955 | r = ath9k_hw_fill_cap_info(ah); |
| 956 | if (r) |
| 957 | return r; |
| 958 | |
Luis R. Rodriguez | aa4058a | 2009-08-03 12:24:45 -0700 | [diff] [blame] | 959 | ath9k_hw_init_11a_eeprom_fix(ah); |
Sujith | f6688cd | 2008-12-07 21:43:10 +0530 | [diff] [blame] | 960 | |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 961 | r = ath9k_hw_init_macaddr(ah); |
| 962 | if (r) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 963 | ath_print(common, ATH_DBG_FATAL, |
| 964 | "Failed to initialize MAC address\n"); |
Luis R. Rodriguez | 95fafca | 2009-08-03 12:24:54 -0700 | [diff] [blame] | 965 | return r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 966 | } |
| 967 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 968 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 969 | ah->tx_trig_level = (AR_FTRIG_256B >> AR_FTRIG_S); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 970 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 971 | ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 972 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 973 | ath9k_init_nfcal_hist_buffer(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 974 | |
Luis R. Rodriguez | 211f585 | 2009-10-06 21:19:07 -0400 | [diff] [blame] | 975 | common->state = ATH_HW_INITIALIZED; |
| 976 | |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 977 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 978 | } |
| 979 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 980 | static void ath9k_hw_init_bb(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 981 | struct ath9k_channel *chan) |
| 982 | { |
| 983 | u32 synthDelay; |
| 984 | |
| 985 | synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY; |
Sujith | 788a3d6 | 2008-11-18 09:09:54 +0530 | [diff] [blame] | 986 | if (IS_CHAN_B(chan)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 987 | synthDelay = (4 * synthDelay) / 22; |
| 988 | else |
| 989 | synthDelay /= 10; |
| 990 | |
| 991 | REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN); |
| 992 | |
| 993 | udelay(synthDelay + BASE_ACTIVATE_DELAY); |
| 994 | } |
| 995 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 996 | static void ath9k_hw_init_qos(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 997 | { |
| 998 | REG_WRITE(ah, AR_MIC_QOS_CONTROL, 0x100aa); |
| 999 | REG_WRITE(ah, AR_MIC_QOS_SELECT, 0x3210); |
| 1000 | |
| 1001 | REG_WRITE(ah, AR_QOS_NO_ACK, |
| 1002 | SM(2, AR_QOS_NO_ACK_TWO_BIT) | |
| 1003 | SM(5, AR_QOS_NO_ACK_BIT_OFF) | |
| 1004 | SM(0, AR_QOS_NO_ACK_BYTE_OFF)); |
| 1005 | |
| 1006 | REG_WRITE(ah, AR_TXOP_X, AR_TXOP_X_VAL); |
| 1007 | REG_WRITE(ah, AR_TXOP_0_3, 0xFFFFFFFF); |
| 1008 | REG_WRITE(ah, AR_TXOP_4_7, 0xFFFFFFFF); |
| 1009 | REG_WRITE(ah, AR_TXOP_8_11, 0xFFFFFFFF); |
| 1010 | REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF); |
| 1011 | } |
| 1012 | |
Luis R. Rodriguez | c75724d | 2009-10-19 02:33:34 -0400 | [diff] [blame] | 1013 | static void ath9k_hw_change_target_baud(struct ath_hw *ah, u32 freq, u32 baud) |
| 1014 | { |
| 1015 | u32 lcr; |
| 1016 | u32 baud_divider = freq * 1000 * 1000 / 16 / baud; |
| 1017 | |
| 1018 | lcr = REG_READ(ah , 0x5100c); |
| 1019 | lcr |= 0x80; |
| 1020 | |
| 1021 | REG_WRITE(ah, 0x5100c, lcr); |
| 1022 | REG_WRITE(ah, 0x51004, (baud_divider >> 8)); |
| 1023 | REG_WRITE(ah, 0x51000, (baud_divider & 0xff)); |
| 1024 | |
| 1025 | lcr &= ~0x80; |
| 1026 | REG_WRITE(ah, 0x5100c, lcr); |
| 1027 | } |
| 1028 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1029 | static void ath9k_hw_init_pll(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1030 | struct ath9k_channel *chan) |
| 1031 | { |
| 1032 | u32 pll; |
| 1033 | |
| 1034 | if (AR_SREV_9100(ah)) { |
| 1035 | if (chan && IS_CHAN_5GHZ(chan)) |
| 1036 | pll = 0x1450; |
| 1037 | else |
| 1038 | pll = 0x1458; |
| 1039 | } else { |
| 1040 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
| 1041 | pll = SM(0x5, AR_RTC_9160_PLL_REFDIV); |
| 1042 | |
| 1043 | if (chan && IS_CHAN_HALF_RATE(chan)) |
| 1044 | pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL); |
| 1045 | else if (chan && IS_CHAN_QUARTER_RATE(chan)) |
| 1046 | pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL); |
| 1047 | |
| 1048 | if (chan && IS_CHAN_5GHZ(chan)) { |
| 1049 | pll |= SM(0x28, AR_RTC_9160_PLL_DIV); |
| 1050 | |
| 1051 | |
| 1052 | if (AR_SREV_9280_20(ah)) { |
| 1053 | if (((chan->channel % 20) == 0) |
| 1054 | || ((chan->channel % 10) == 0)) |
| 1055 | pll = 0x2850; |
| 1056 | else |
| 1057 | pll = 0x142c; |
| 1058 | } |
| 1059 | } else { |
| 1060 | pll |= SM(0x2c, AR_RTC_9160_PLL_DIV); |
| 1061 | } |
| 1062 | |
| 1063 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { |
| 1064 | |
| 1065 | pll = SM(0x5, AR_RTC_9160_PLL_REFDIV); |
| 1066 | |
| 1067 | if (chan && IS_CHAN_HALF_RATE(chan)) |
| 1068 | pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL); |
| 1069 | else if (chan && IS_CHAN_QUARTER_RATE(chan)) |
| 1070 | pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL); |
| 1071 | |
| 1072 | if (chan && IS_CHAN_5GHZ(chan)) |
| 1073 | pll |= SM(0x50, AR_RTC_9160_PLL_DIV); |
| 1074 | else |
| 1075 | pll |= SM(0x58, AR_RTC_9160_PLL_DIV); |
| 1076 | } else { |
| 1077 | pll = AR_RTC_PLL_REFDIV_5 | AR_RTC_PLL_DIV2; |
| 1078 | |
| 1079 | if (chan && IS_CHAN_HALF_RATE(chan)) |
| 1080 | pll |= SM(0x1, AR_RTC_PLL_CLKSEL); |
| 1081 | else if (chan && IS_CHAN_QUARTER_RATE(chan)) |
| 1082 | pll |= SM(0x2, AR_RTC_PLL_CLKSEL); |
| 1083 | |
| 1084 | if (chan && IS_CHAN_5GHZ(chan)) |
| 1085 | pll |= SM(0xa, AR_RTC_PLL_DIV); |
| 1086 | else |
| 1087 | pll |= SM(0xb, AR_RTC_PLL_DIV); |
| 1088 | } |
| 1089 | } |
Gabor Juhos | d03a66c | 2009-01-14 20:17:09 +0100 | [diff] [blame] | 1090 | REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1091 | |
Luis R. Rodriguez | c75724d | 2009-10-19 02:33:34 -0400 | [diff] [blame] | 1092 | /* Switch the core clock for ar9271 to 117Mhz */ |
| 1093 | if (AR_SREV_9271(ah)) { |
| 1094 | if ((pll == 0x142c) || (pll == 0x2850) ) { |
| 1095 | udelay(500); |
| 1096 | /* set CLKOBS to output AHB clock */ |
| 1097 | REG_WRITE(ah, 0x7020, 0xe); |
| 1098 | /* |
| 1099 | * 0x304: 117Mhz, ahb_ratio: 1x1 |
| 1100 | * 0x306: 40Mhz, ahb_ratio: 1x1 |
| 1101 | */ |
| 1102 | REG_WRITE(ah, 0x50040, 0x304); |
| 1103 | /* |
| 1104 | * makes adjustments for the baud dividor to keep the |
| 1105 | * targetted baud rate based on the used core clock. |
| 1106 | */ |
| 1107 | ath9k_hw_change_target_baud(ah, AR9271_CORE_CLOCK, |
| 1108 | AR9271_TARGET_BAUD_RATE); |
| 1109 | } |
| 1110 | } |
| 1111 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1112 | udelay(RTC_PLL_SETTLE_DELAY); |
| 1113 | |
| 1114 | REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK); |
| 1115 | } |
| 1116 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1117 | static void ath9k_hw_init_chain_masks(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1118 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1119 | int rx_chainmask, tx_chainmask; |
| 1120 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1121 | rx_chainmask = ah->rxchainmask; |
| 1122 | tx_chainmask = ah->txchainmask; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1123 | |
| 1124 | switch (rx_chainmask) { |
| 1125 | case 0x5: |
| 1126 | REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, |
| 1127 | AR_PHY_SWAP_ALT_CHAIN); |
| 1128 | case 0x3: |
Sujith | cb53a15 | 2009-11-16 11:40:57 +0530 | [diff] [blame] | 1129 | if (ah->hw_version.macVersion == AR_SREV_REVISION_5416_10) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1130 | REG_WRITE(ah, AR_PHY_RX_CHAINMASK, 0x7); |
| 1131 | REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, 0x7); |
| 1132 | break; |
| 1133 | } |
| 1134 | case 0x1: |
| 1135 | case 0x2: |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1136 | case 0x7: |
| 1137 | REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx_chainmask); |
| 1138 | REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx_chainmask); |
| 1139 | break; |
| 1140 | default: |
| 1141 | break; |
| 1142 | } |
| 1143 | |
| 1144 | REG_WRITE(ah, AR_SELFGEN_MASK, tx_chainmask); |
| 1145 | if (tx_chainmask == 0x5) { |
| 1146 | REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, |
| 1147 | AR_PHY_SWAP_ALT_CHAIN); |
| 1148 | } |
| 1149 | if (AR_SREV_9100(ah)) |
| 1150 | REG_WRITE(ah, AR_PHY_ANALOG_SWAP, |
| 1151 | REG_READ(ah, AR_PHY_ANALOG_SWAP) | 0x00000001); |
| 1152 | } |
| 1153 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1154 | static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 1155 | enum nl80211_iftype opmode) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1156 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1157 | ah->mask_reg = AR_IMR_TXERR | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1158 | AR_IMR_TXURN | |
| 1159 | AR_IMR_RXERR | |
| 1160 | AR_IMR_RXORN | |
| 1161 | AR_IMR_BCNMISC; |
| 1162 | |
Sujith | 0ce024c | 2009-12-14 14:57:00 +0530 | [diff] [blame^] | 1163 | if (ah->config.rx_intr_mitigation) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1164 | ah->mask_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1165 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1166 | ah->mask_reg |= AR_IMR_RXOK; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1167 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1168 | ah->mask_reg |= AR_IMR_TXOK; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1169 | |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 1170 | if (opmode == NL80211_IFTYPE_AP) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1171 | ah->mask_reg |= AR_IMR_MIB; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1172 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1173 | REG_WRITE(ah, AR_IMR, ah->mask_reg); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1174 | REG_WRITE(ah, AR_IMR_S2, REG_READ(ah, AR_IMR_S2) | AR_IMR_S2_GTT); |
| 1175 | |
| 1176 | if (!AR_SREV_9100(ah)) { |
| 1177 | REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF); |
| 1178 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, AR_INTR_SYNC_DEFAULT); |
| 1179 | REG_WRITE(ah, AR_INTR_SYNC_MASK, 0); |
| 1180 | } |
| 1181 | } |
| 1182 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1183 | static bool ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1184 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1185 | if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1186 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, |
| 1187 | "bad ack timeout %u\n", us); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1188 | ah->acktimeout = (u32) -1; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1189 | return false; |
| 1190 | } else { |
| 1191 | REG_RMW_FIELD(ah, AR_TIME_OUT, |
| 1192 | AR_TIME_OUT_ACK, ath9k_hw_mac_to_clks(ah, us)); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1193 | ah->acktimeout = us; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1194 | return true; |
| 1195 | } |
| 1196 | } |
| 1197 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1198 | static bool ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1199 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1200 | if (us > ath9k_hw_mac_to_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1201 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, |
| 1202 | "bad cts timeout %u\n", us); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1203 | ah->ctstimeout = (u32) -1; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1204 | return false; |
| 1205 | } else { |
| 1206 | REG_RMW_FIELD(ah, AR_TIME_OUT, |
| 1207 | AR_TIME_OUT_CTS, ath9k_hw_mac_to_clks(ah, us)); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1208 | ah->ctstimeout = us; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1209 | return true; |
| 1210 | } |
| 1211 | } |
| 1212 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1213 | static bool ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1214 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1215 | if (tu > 0xFFFF) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1216 | ath_print(ath9k_hw_common(ah), ATH_DBG_XMIT, |
| 1217 | "bad global tx timeout %u\n", tu); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1218 | ah->globaltxtimeout = (u32) -1; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1219 | return false; |
| 1220 | } else { |
| 1221 | REG_RMW_FIELD(ah, AR_GTXTO, AR_GTXTO_TIMEOUT_LIMIT, tu); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1222 | ah->globaltxtimeout = tu; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1223 | return true; |
| 1224 | } |
| 1225 | } |
| 1226 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1227 | static void ath9k_hw_init_user_settings(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1228 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1229 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n", |
| 1230 | ah->misc_mode); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1231 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1232 | if (ah->misc_mode != 0) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1233 | REG_WRITE(ah, AR_PCU_MISC, |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1234 | REG_READ(ah, AR_PCU_MISC) | ah->misc_mode); |
| 1235 | if (ah->slottime != (u32) -1) |
| 1236 | ath9k_hw_setslottime(ah, ah->slottime); |
| 1237 | if (ah->acktimeout != (u32) -1) |
| 1238 | ath9k_hw_set_ack_timeout(ah, ah->acktimeout); |
| 1239 | if (ah->ctstimeout != (u32) -1) |
| 1240 | ath9k_hw_set_cts_timeout(ah, ah->ctstimeout); |
| 1241 | if (ah->globaltxtimeout != (u32) -1) |
| 1242 | ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1243 | } |
| 1244 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1245 | void ath9k_hw_detach(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1246 | { |
Luis R. Rodriguez | 211f585 | 2009-10-06 21:19:07 -0400 | [diff] [blame] | 1247 | struct ath_common *common = ath9k_hw_common(ah); |
| 1248 | |
| 1249 | if (common->state <= ATH_HW_INITIALIZED) |
| 1250 | goto free_hw; |
| 1251 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1252 | if (!AR_SREV_9100(ah)) |
Luis R. Rodriguez | e70c0cf | 2009-08-03 12:24:51 -0700 | [diff] [blame] | 1253 | ath9k_hw_ani_disable(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1254 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 1255 | ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP); |
Luis R. Rodriguez | 211f585 | 2009-10-06 21:19:07 -0400 | [diff] [blame] | 1256 | |
| 1257 | free_hw: |
Luis R. Rodriguez | dc51dd5 | 2009-10-19 02:33:39 -0400 | [diff] [blame] | 1258 | if (!AR_SREV_9280_10_OR_LATER(ah)) |
| 1259 | ath9k_hw_rf_free_ext_banks(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1260 | kfree(ah); |
Luis R. Rodriguez | 9db6b6a | 2009-08-03 12:24:52 -0700 | [diff] [blame] | 1261 | ah = NULL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1262 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1263 | EXPORT_SYMBOL(ath9k_hw_detach); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1264 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1265 | /*******/ |
| 1266 | /* INI */ |
| 1267 | /*******/ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1268 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1269 | static void ath9k_hw_override_ini(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1270 | struct ath9k_channel *chan) |
| 1271 | { |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1272 | u32 val; |
| 1273 | |
| 1274 | if (AR_SREV_9271(ah)) { |
| 1275 | /* |
| 1276 | * Enable spectral scan to solution for issues with stuck |
| 1277 | * beacons on AR9271 1.0. The beacon stuck issue is not seeon on |
| 1278 | * AR9271 1.1 |
| 1279 | */ |
| 1280 | if (AR_SREV_9271_10(ah)) { |
Luis R. Rodriguez | ec11bb8 | 2009-10-27 12:59:36 -0400 | [diff] [blame] | 1281 | val = REG_READ(ah, AR_PHY_SPECTRAL_SCAN) | |
| 1282 | AR_PHY_SPECTRAL_SCAN_ENABLE; |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1283 | REG_WRITE(ah, AR_PHY_SPECTRAL_SCAN, val); |
| 1284 | } |
| 1285 | else if (AR_SREV_9271_11(ah)) |
| 1286 | /* |
| 1287 | * change AR_PHY_RF_CTL3 setting to fix MAC issue |
| 1288 | * present on AR9271 1.1 |
| 1289 | */ |
| 1290 | REG_WRITE(ah, AR_PHY_RF_CTL3, 0x3a020001); |
| 1291 | return; |
| 1292 | } |
| 1293 | |
Senthil Balasubramanian | 8aa15e1 | 2008-12-08 19:43:50 +0530 | [diff] [blame] | 1294 | /* |
| 1295 | * Set the RX_ABORT and RX_DIS and clear if off only after |
| 1296 | * RXE is set for MAC. This prevents frames with corrupted |
| 1297 | * descriptor status. |
| 1298 | */ |
| 1299 | REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); |
| 1300 | |
Vasanthakumar Thiagarajan | 204d794 | 2009-09-17 09:26:14 +0530 | [diff] [blame] | 1301 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
| 1302 | val = REG_READ(ah, AR_PCU_MISC_MODE2) & |
| 1303 | (~AR_PCU_MISC_MODE2_HWWAR1); |
| 1304 | |
| 1305 | if (AR_SREV_9287_10_OR_LATER(ah)) |
| 1306 | val = val & (~AR_PCU_MISC_MODE2_HWWAR2); |
| 1307 | |
| 1308 | REG_WRITE(ah, AR_PCU_MISC_MODE2, val); |
| 1309 | } |
Senthil Balasubramanian | 8aa15e1 | 2008-12-08 19:43:50 +0530 | [diff] [blame] | 1310 | |
Gabor Juhos | a8c96d3 | 2009-03-06 09:08:51 +0100 | [diff] [blame] | 1311 | if (!AR_SREV_5416_20_OR_LATER(ah) || |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1312 | AR_SREV_9280_10_OR_LATER(ah)) |
| 1313 | return; |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1314 | /* |
| 1315 | * Disable BB clock gating |
| 1316 | * Necessary to avoid issues on AR5416 2.0 |
| 1317 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1318 | REG_WRITE(ah, 0x9800 + (651 << 2), 0x11); |
| 1319 | } |
| 1320 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1321 | static u32 ath9k_hw_def_ini_fixup(struct ath_hw *ah, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1322 | struct ar5416_eeprom_def *pEepData, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1323 | u32 reg, u32 value) |
| 1324 | { |
| 1325 | struct base_eep_header *pBase = &(pEepData->baseEepHeader); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1326 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1327 | |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 1328 | switch (ah->hw_version.devid) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1329 | case AR9280_DEVID_PCI: |
| 1330 | if (reg == 0x7894) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1331 | ath_print(common, ATH_DBG_EEPROM, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1332 | "ini VAL: %x EEPROM: %x\n", value, |
| 1333 | (pBase->version & 0xff)); |
| 1334 | |
| 1335 | if ((pBase->version & 0xff) > 0x0a) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1336 | ath_print(common, ATH_DBG_EEPROM, |
| 1337 | "PWDCLKIND: %d\n", |
| 1338 | pBase->pwdclkind); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1339 | value &= ~AR_AN_TOP2_PWDCLKIND; |
| 1340 | value |= AR_AN_TOP2_PWDCLKIND & |
| 1341 | (pBase->pwdclkind << AR_AN_TOP2_PWDCLKIND_S); |
| 1342 | } else { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1343 | ath_print(common, ATH_DBG_EEPROM, |
| 1344 | "PWDCLKIND Earlier Rev\n"); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1345 | } |
| 1346 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1347 | ath_print(common, ATH_DBG_EEPROM, |
| 1348 | "final ini VAL: %x\n", value); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1349 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1350 | break; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1351 | } |
| 1352 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1353 | return value; |
| 1354 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1355 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1356 | static u32 ath9k_hw_ini_fixup(struct ath_hw *ah, |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1357 | struct ar5416_eeprom_def *pEepData, |
| 1358 | u32 reg, u32 value) |
| 1359 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1360 | if (ah->eep_map == EEP_MAP_4KBITS) |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1361 | return value; |
| 1362 | else |
| 1363 | return ath9k_hw_def_ini_fixup(ah, pEepData, reg, value); |
| 1364 | } |
| 1365 | |
Senthil Balasubramanian | 8bd1d07 | 2009-02-12 13:57:03 +0530 | [diff] [blame] | 1366 | static void ath9k_olc_init(struct ath_hw *ah) |
| 1367 | { |
| 1368 | u32 i; |
| 1369 | |
Vivek Natarajan | db91f2e | 2009-08-14 11:27:16 +0530 | [diff] [blame] | 1370 | if (OLC_FOR_AR9287_10_LATER) { |
| 1371 | REG_SET_BIT(ah, AR_PHY_TX_PWRCTRL9, |
| 1372 | AR_PHY_TX_PWRCTRL9_RES_DC_REMOVAL); |
| 1373 | ath9k_hw_analog_shift_rmw(ah, AR9287_AN_TXPC0, |
| 1374 | AR9287_AN_TXPC0_TXPCMODE, |
| 1375 | AR9287_AN_TXPC0_TXPCMODE_S, |
| 1376 | AR9287_AN_TXPC0_TXPCMODE_TEMPSENSE); |
| 1377 | udelay(100); |
| 1378 | } else { |
| 1379 | for (i = 0; i < AR9280_TX_GAIN_TABLE_SIZE; i++) |
| 1380 | ah->originalGain[i] = |
| 1381 | MS(REG_READ(ah, AR_PHY_TX_GAIN_TBL1 + i * 4), |
| 1382 | AR_PHY_TX_GAIN); |
| 1383 | ah->PDADCdelta = 0; |
| 1384 | } |
Senthil Balasubramanian | 8bd1d07 | 2009-02-12 13:57:03 +0530 | [diff] [blame] | 1385 | } |
| 1386 | |
Bob Copeland | 3a702e4 | 2009-03-30 22:30:29 -0400 | [diff] [blame] | 1387 | static u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, |
| 1388 | struct ath9k_channel *chan) |
| 1389 | { |
| 1390 | u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band); |
| 1391 | |
| 1392 | if (IS_CHAN_B(chan)) |
| 1393 | ctl |= CTL_11B; |
| 1394 | else if (IS_CHAN_G(chan)) |
| 1395 | ctl |= CTL_11G; |
| 1396 | else |
| 1397 | ctl |= CTL_11A; |
| 1398 | |
| 1399 | return ctl; |
| 1400 | } |
| 1401 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1402 | static int ath9k_hw_process_ini(struct ath_hw *ah, |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1403 | struct ath9k_channel *chan) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1404 | { |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 1405 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1406 | int i, regWrites = 0; |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1407 | struct ieee80211_channel *channel = chan->chan; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1408 | u32 modesIndex, freqIndex; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1409 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1410 | switch (chan->chanmode) { |
| 1411 | case CHANNEL_A: |
| 1412 | case CHANNEL_A_HT20: |
| 1413 | modesIndex = 1; |
| 1414 | freqIndex = 1; |
| 1415 | break; |
| 1416 | case CHANNEL_A_HT40PLUS: |
| 1417 | case CHANNEL_A_HT40MINUS: |
| 1418 | modesIndex = 2; |
| 1419 | freqIndex = 1; |
| 1420 | break; |
| 1421 | case CHANNEL_G: |
| 1422 | case CHANNEL_G_HT20: |
| 1423 | case CHANNEL_B: |
| 1424 | modesIndex = 4; |
| 1425 | freqIndex = 2; |
| 1426 | break; |
| 1427 | case CHANNEL_G_HT40PLUS: |
| 1428 | case CHANNEL_G_HT40MINUS: |
| 1429 | modesIndex = 3; |
| 1430 | freqIndex = 2; |
| 1431 | break; |
| 1432 | |
| 1433 | default: |
| 1434 | return -EINVAL; |
| 1435 | } |
| 1436 | |
| 1437 | REG_WRITE(ah, AR_PHY(0), 0x00000007); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1438 | REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO); |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 1439 | ah->eep_ops->set_addac(ah, chan); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1440 | |
Gabor Juhos | a8c96d3 | 2009-03-06 09:08:51 +0100 | [diff] [blame] | 1441 | if (AR_SREV_5416_22_OR_LATER(ah)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1442 | REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1443 | } else { |
| 1444 | struct ar5416IniArray temp; |
| 1445 | u32 addacSize = |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1446 | sizeof(u32) * ah->iniAddac.ia_rows * |
| 1447 | ah->iniAddac.ia_columns; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1448 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1449 | memcpy(ah->addac5416_21, |
| 1450 | ah->iniAddac.ia_array, addacSize); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1451 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1452 | (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1453 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1454 | temp.ia_array = ah->addac5416_21; |
| 1455 | temp.ia_columns = ah->iniAddac.ia_columns; |
| 1456 | temp.ia_rows = ah->iniAddac.ia_rows; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1457 | REG_WRITE_ARRAY(&temp, 1, regWrites); |
| 1458 | } |
| 1459 | |
| 1460 | REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC); |
| 1461 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1462 | for (i = 0; i < ah->iniModes.ia_rows; i++) { |
| 1463 | u32 reg = INI_RA(&ah->iniModes, i, 0); |
| 1464 | u32 val = INI_RA(&ah->iniModes, i, modesIndex); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1465 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1466 | REG_WRITE(ah, reg, val); |
| 1467 | |
| 1468 | if (reg >= 0x7800 && reg < 0x78a0 |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1469 | && ah->config.analog_shiftreg) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1470 | udelay(100); |
| 1471 | } |
| 1472 | |
| 1473 | DO_DELAY(regWrites); |
| 1474 | } |
| 1475 | |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 1476 | if (AR_SREV_9280(ah) || AR_SREV_9287_10_OR_LATER(ah)) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1477 | REG_WRITE_ARRAY(&ah->iniModesRxGain, modesIndex, regWrites); |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 1478 | |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 1479 | if (AR_SREV_9280(ah) || AR_SREV_9285_12_OR_LATER(ah) || |
| 1480 | AR_SREV_9287_10_OR_LATER(ah)) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1481 | REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); |
Senthil Balasubramanian | 9f80420 | 2008-11-13 17:58:41 +0530 | [diff] [blame] | 1482 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1483 | for (i = 0; i < ah->iniCommon.ia_rows; i++) { |
| 1484 | u32 reg = INI_RA(&ah->iniCommon, i, 0); |
| 1485 | u32 val = INI_RA(&ah->iniCommon, i, 1); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1486 | |
| 1487 | REG_WRITE(ah, reg, val); |
| 1488 | |
| 1489 | if (reg >= 0x7800 && reg < 0x78a0 |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1490 | && ah->config.analog_shiftreg) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1491 | udelay(100); |
| 1492 | } |
| 1493 | |
| 1494 | DO_DELAY(regWrites); |
| 1495 | } |
| 1496 | |
Luis R. Rodriguez | 896ff26 | 2009-10-19 02:33:44 -0400 | [diff] [blame] | 1497 | ath9k_hw_write_regs(ah, freqIndex, regWrites); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1498 | |
Luis R. Rodriguez | 8564328 | 2009-10-19 02:33:33 -0400 | [diff] [blame] | 1499 | if (AR_SREV_9271_10(ah)) |
| 1500 | REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only, |
| 1501 | modesIndex, regWrites); |
| 1502 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1503 | if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1504 | REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1505 | regWrites); |
| 1506 | } |
| 1507 | |
| 1508 | ath9k_hw_override_ini(ah, chan); |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1509 | ath9k_hw_set_regs(ah, chan); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1510 | ath9k_hw_init_chain_masks(ah); |
| 1511 | |
Senthil Balasubramanian | 8bd1d07 | 2009-02-12 13:57:03 +0530 | [diff] [blame] | 1512 | if (OLC_FOR_AR9280_20_LATER) |
| 1513 | ath9k_olc_init(ah); |
| 1514 | |
Vasanthakumar Thiagarajan | 8fbff4b | 2009-05-08 17:54:51 -0700 | [diff] [blame] | 1515 | ah->eep_ops->set_txpower(ah, chan, |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 1516 | ath9k_regd_get_ctl(regulatory, chan), |
Vasanthakumar Thiagarajan | 8fbff4b | 2009-05-08 17:54:51 -0700 | [diff] [blame] | 1517 | channel->max_antenna_gain * 2, |
| 1518 | channel->max_power * 2, |
| 1519 | min((u32) MAX_RATE_POWER, |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 1520 | (u32) regulatory->power_limit)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1521 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1522 | if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1523 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 1524 | "ar5416SetRfRegs failed\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1525 | return -EIO; |
| 1526 | } |
| 1527 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1528 | return 0; |
| 1529 | } |
| 1530 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1531 | /****************************************/ |
| 1532 | /* Reset and Channel Switching Routines */ |
| 1533 | /****************************************/ |
| 1534 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1535 | static void ath9k_hw_set_rfmode(struct ath_hw *ah, struct ath9k_channel *chan) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1536 | { |
| 1537 | u32 rfMode = 0; |
| 1538 | |
| 1539 | if (chan == NULL) |
| 1540 | return; |
| 1541 | |
| 1542 | rfMode |= (IS_CHAN_B(chan) || IS_CHAN_G(chan)) |
| 1543 | ? AR_PHY_MODE_DYNAMIC : AR_PHY_MODE_OFDM; |
| 1544 | |
| 1545 | if (!AR_SREV_9280_10_OR_LATER(ah)) |
| 1546 | rfMode |= (IS_CHAN_5GHZ(chan)) ? |
| 1547 | AR_PHY_MODE_RF5GHZ : AR_PHY_MODE_RF2GHZ; |
| 1548 | |
| 1549 | if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) |
| 1550 | rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE); |
| 1551 | |
| 1552 | REG_WRITE(ah, AR_PHY_MODE, rfMode); |
| 1553 | } |
| 1554 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1555 | static void ath9k_hw_mark_phy_inactive(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1556 | { |
| 1557 | REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS); |
| 1558 | } |
| 1559 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1560 | static inline void ath9k_hw_set_dma(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1561 | { |
| 1562 | u32 regval; |
| 1563 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1564 | /* |
| 1565 | * set AHB_MODE not to do cacheline prefetches |
| 1566 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1567 | regval = REG_READ(ah, AR_AHB_MODE); |
| 1568 | REG_WRITE(ah, AR_AHB_MODE, regval | AR_AHB_PREFETCH_RD_EN); |
| 1569 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1570 | /* |
| 1571 | * let mac dma reads be in 128 byte chunks |
| 1572 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1573 | regval = REG_READ(ah, AR_TXCFG) & ~AR_TXCFG_DMASZ_MASK; |
| 1574 | REG_WRITE(ah, AR_TXCFG, regval | AR_TXCFG_DMASZ_128B); |
| 1575 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1576 | /* |
| 1577 | * Restore TX Trigger Level to its pre-reset value. |
| 1578 | * The initial value depends on whether aggregation is enabled, and is |
| 1579 | * adjusted whenever underruns are detected. |
| 1580 | */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1581 | REG_RMW_FIELD(ah, AR_TXCFG, AR_FTRIG, ah->tx_trig_level); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1582 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1583 | /* |
| 1584 | * let mac dma writes be in 128 byte chunks |
| 1585 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1586 | regval = REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_DMASZ_MASK; |
| 1587 | REG_WRITE(ah, AR_RXCFG, regval | AR_RXCFG_DMASZ_128B); |
| 1588 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1589 | /* |
| 1590 | * Setup receive FIFO threshold to hold off TX activities |
| 1591 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1592 | REG_WRITE(ah, AR_RXFIFO_CFG, 0x200); |
| 1593 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1594 | /* |
| 1595 | * reduce the number of usable entries in PCU TXBUF to avoid |
| 1596 | * wrap around issues. |
| 1597 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1598 | if (AR_SREV_9285(ah)) { |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1599 | /* For AR9285 the number of Fifos are reduced to half. |
| 1600 | * So set the usable tx buf size also to half to |
| 1601 | * avoid data/delimiter underruns |
| 1602 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1603 | REG_WRITE(ah, AR_PCU_TXBUF_CTRL, |
| 1604 | AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE); |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1605 | } else if (!AR_SREV_9271(ah)) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1606 | REG_WRITE(ah, AR_PCU_TXBUF_CTRL, |
| 1607 | AR_PCU_TXBUF_CTRL_USABLE_SIZE); |
| 1608 | } |
| 1609 | } |
| 1610 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1611 | static void ath9k_hw_set_operating_mode(struct ath_hw *ah, int opmode) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1612 | { |
| 1613 | u32 val; |
| 1614 | |
| 1615 | val = REG_READ(ah, AR_STA_ID1); |
| 1616 | val &= ~(AR_STA_ID1_STA_AP | AR_STA_ID1_ADHOC); |
| 1617 | switch (opmode) { |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 1618 | case NL80211_IFTYPE_AP: |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1619 | REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_STA_AP |
| 1620 | | AR_STA_ID1_KSRCH_MODE); |
| 1621 | REG_CLR_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION); |
| 1622 | break; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 1623 | case NL80211_IFTYPE_ADHOC: |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 1624 | case NL80211_IFTYPE_MESH_POINT: |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1625 | REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_ADHOC |
| 1626 | | AR_STA_ID1_KSRCH_MODE); |
| 1627 | REG_SET_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION); |
| 1628 | break; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 1629 | case NL80211_IFTYPE_STATION: |
| 1630 | case NL80211_IFTYPE_MONITOR: |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1631 | REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_KSRCH_MODE); |
| 1632 | break; |
| 1633 | } |
| 1634 | } |
| 1635 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1636 | static inline void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1637 | u32 coef_scaled, |
| 1638 | u32 *coef_mantissa, |
| 1639 | u32 *coef_exponent) |
| 1640 | { |
| 1641 | u32 coef_exp, coef_man; |
| 1642 | |
| 1643 | for (coef_exp = 31; coef_exp > 0; coef_exp--) |
| 1644 | if ((coef_scaled >> coef_exp) & 0x1) |
| 1645 | break; |
| 1646 | |
| 1647 | coef_exp = 14 - (coef_exp - COEF_SCALE_S); |
| 1648 | |
| 1649 | coef_man = coef_scaled + (1 << (COEF_SCALE_S - coef_exp - 1)); |
| 1650 | |
| 1651 | *coef_mantissa = coef_man >> (COEF_SCALE_S - coef_exp); |
| 1652 | *coef_exponent = coef_exp - 16; |
| 1653 | } |
| 1654 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1655 | static void ath9k_hw_set_delta_slope(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1656 | struct ath9k_channel *chan) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1657 | { |
| 1658 | u32 coef_scaled, ds_coef_exp, ds_coef_man; |
| 1659 | u32 clockMhzScaled = 0x64000000; |
| 1660 | struct chan_centers centers; |
| 1661 | |
| 1662 | if (IS_CHAN_HALF_RATE(chan)) |
| 1663 | clockMhzScaled = clockMhzScaled >> 1; |
| 1664 | else if (IS_CHAN_QUARTER_RATE(chan)) |
| 1665 | clockMhzScaled = clockMhzScaled >> 2; |
| 1666 | |
| 1667 | ath9k_hw_get_channel_centers(ah, chan, ¢ers); |
| 1668 | coef_scaled = clockMhzScaled / centers.synth_center; |
| 1669 | |
| 1670 | ath9k_hw_get_delta_slope_vals(ah, coef_scaled, &ds_coef_man, |
| 1671 | &ds_coef_exp); |
| 1672 | |
| 1673 | REG_RMW_FIELD(ah, AR_PHY_TIMING3, |
| 1674 | AR_PHY_TIMING3_DSC_MAN, ds_coef_man); |
| 1675 | REG_RMW_FIELD(ah, AR_PHY_TIMING3, |
| 1676 | AR_PHY_TIMING3_DSC_EXP, ds_coef_exp); |
| 1677 | |
| 1678 | coef_scaled = (9 * coef_scaled) / 10; |
| 1679 | |
| 1680 | ath9k_hw_get_delta_slope_vals(ah, coef_scaled, &ds_coef_man, |
| 1681 | &ds_coef_exp); |
| 1682 | |
| 1683 | REG_RMW_FIELD(ah, AR_PHY_HALFGI, |
| 1684 | AR_PHY_HALFGI_DSC_MAN, ds_coef_man); |
| 1685 | REG_RMW_FIELD(ah, AR_PHY_HALFGI, |
| 1686 | AR_PHY_HALFGI_DSC_EXP, ds_coef_exp); |
| 1687 | } |
| 1688 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1689 | static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1690 | { |
| 1691 | u32 rst_flags; |
| 1692 | u32 tmpReg; |
| 1693 | |
Sujith | 7076849 | 2009-02-16 13:23:12 +0530 | [diff] [blame] | 1694 | if (AR_SREV_9100(ah)) { |
| 1695 | u32 val = REG_READ(ah, AR_RTC_DERIVED_CLK); |
| 1696 | val &= ~AR_RTC_DERIVED_CLK_PERIOD; |
| 1697 | val |= SM(1, AR_RTC_DERIVED_CLK_PERIOD); |
| 1698 | REG_WRITE(ah, AR_RTC_DERIVED_CLK, val); |
| 1699 | (void)REG_READ(ah, AR_RTC_DERIVED_CLK); |
| 1700 | } |
| 1701 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1702 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | |
| 1703 | AR_RTC_FORCE_WAKE_ON_INT); |
| 1704 | |
| 1705 | if (AR_SREV_9100(ah)) { |
| 1706 | rst_flags = AR_RTC_RC_MAC_WARM | AR_RTC_RC_MAC_COLD | |
| 1707 | AR_RTC_RC_COLD_RESET | AR_RTC_RC_WARM_RESET; |
| 1708 | } else { |
| 1709 | tmpReg = REG_READ(ah, AR_INTR_SYNC_CAUSE); |
| 1710 | if (tmpReg & |
| 1711 | (AR_INTR_SYNC_LOCAL_TIMEOUT | |
| 1712 | AR_INTR_SYNC_RADM_CPL_TIMEOUT)) { |
| 1713 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0); |
| 1714 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); |
| 1715 | } else { |
| 1716 | REG_WRITE(ah, AR_RC, AR_RC_AHB); |
| 1717 | } |
| 1718 | |
| 1719 | rst_flags = AR_RTC_RC_MAC_WARM; |
| 1720 | if (type == ATH9K_RESET_COLD) |
| 1721 | rst_flags |= AR_RTC_RC_MAC_COLD; |
| 1722 | } |
| 1723 | |
Gabor Juhos | d03a66c | 2009-01-14 20:17:09 +0100 | [diff] [blame] | 1724 | REG_WRITE(ah, AR_RTC_RC, rst_flags); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1725 | udelay(50); |
| 1726 | |
Gabor Juhos | d03a66c | 2009-01-14 20:17:09 +0100 | [diff] [blame] | 1727 | REG_WRITE(ah, AR_RTC_RC, 0); |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1728 | if (!ath9k_hw_wait(ah, AR_RTC_RC, AR_RTC_RC_M, 0, AH_WAIT_TIMEOUT)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1729 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, |
| 1730 | "RTC stuck in MAC reset\n"); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1731 | return false; |
| 1732 | } |
| 1733 | |
| 1734 | if (!AR_SREV_9100(ah)) |
| 1735 | REG_WRITE(ah, AR_RC, 0); |
| 1736 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1737 | if (AR_SREV_9100(ah)) |
| 1738 | udelay(50); |
| 1739 | |
| 1740 | return true; |
| 1741 | } |
| 1742 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1743 | static bool ath9k_hw_set_reset_power_on(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1744 | { |
| 1745 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | |
| 1746 | AR_RTC_FORCE_WAKE_ON_INT); |
| 1747 | |
Vasanthakumar Thiagarajan | 1c29ce6 | 2009-08-31 17:48:36 +0530 | [diff] [blame] | 1748 | if (!AR_SREV_9100(ah)) |
| 1749 | REG_WRITE(ah, AR_RC, AR_RC_AHB); |
| 1750 | |
Gabor Juhos | d03a66c | 2009-01-14 20:17:09 +0100 | [diff] [blame] | 1751 | REG_WRITE(ah, AR_RTC_RESET, 0); |
Senthil Balasubramanian | 8bd1d07 | 2009-02-12 13:57:03 +0530 | [diff] [blame] | 1752 | udelay(2); |
Vasanthakumar Thiagarajan | 1c29ce6 | 2009-08-31 17:48:36 +0530 | [diff] [blame] | 1753 | |
| 1754 | if (!AR_SREV_9100(ah)) |
| 1755 | REG_WRITE(ah, AR_RC, 0); |
| 1756 | |
Gabor Juhos | d03a66c | 2009-01-14 20:17:09 +0100 | [diff] [blame] | 1757 | REG_WRITE(ah, AR_RTC_RESET, 1); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1758 | |
| 1759 | if (!ath9k_hw_wait(ah, |
| 1760 | AR_RTC_STATUS, |
| 1761 | AR_RTC_STATUS_M, |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1762 | AR_RTC_STATUS_ON, |
| 1763 | AH_WAIT_TIMEOUT)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1764 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, |
| 1765 | "RTC not waking up\n"); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1766 | return false; |
| 1767 | } |
| 1768 | |
| 1769 | ath9k_hw_read_revisions(ah); |
| 1770 | |
| 1771 | return ath9k_hw_set_reset(ah, ATH9K_RESET_WARM); |
| 1772 | } |
| 1773 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1774 | static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1775 | { |
| 1776 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, |
| 1777 | AR_RTC_FORCE_WAKE_EN | AR_RTC_FORCE_WAKE_ON_INT); |
| 1778 | |
| 1779 | switch (type) { |
| 1780 | case ATH9K_RESET_POWER_ON: |
| 1781 | return ath9k_hw_set_reset_power_on(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1782 | case ATH9K_RESET_WARM: |
| 1783 | case ATH9K_RESET_COLD: |
| 1784 | return ath9k_hw_set_reset(ah, type); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1785 | default: |
| 1786 | return false; |
| 1787 | } |
| 1788 | } |
| 1789 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1790 | static void ath9k_hw_set_regs(struct ath_hw *ah, struct ath9k_channel *chan) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1791 | { |
| 1792 | u32 phymode; |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1793 | u32 enableDacFifo = 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1794 | |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1795 | if (AR_SREV_9285_10_OR_LATER(ah)) |
| 1796 | enableDacFifo = (REG_READ(ah, AR_PHY_TURBO) & |
| 1797 | AR_PHY_FC_ENABLE_DAC_FIFO); |
| 1798 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1799 | phymode = AR_PHY_FC_HT_EN | AR_PHY_FC_SHORT_GI_40 |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1800 | | AR_PHY_FC_SINGLE_HT_LTF1 | AR_PHY_FC_WALSH | enableDacFifo; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1801 | |
| 1802 | if (IS_CHAN_HT40(chan)) { |
| 1803 | phymode |= AR_PHY_FC_DYN2040_EN; |
| 1804 | |
| 1805 | if ((chan->chanmode == CHANNEL_A_HT40PLUS) || |
| 1806 | (chan->chanmode == CHANNEL_G_HT40PLUS)) |
| 1807 | phymode |= AR_PHY_FC_DYN2040_PRI_CH; |
| 1808 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1809 | } |
| 1810 | REG_WRITE(ah, AR_PHY_TURBO, phymode); |
| 1811 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1812 | ath9k_hw_set11nmac2040(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1813 | |
| 1814 | REG_WRITE(ah, AR_GTXTO, 25 << AR_GTXTO_TIMEOUT_LIMIT_S); |
| 1815 | REG_WRITE(ah, AR_CST, 0xF << AR_CST_TIMEOUT_LIMIT_S); |
| 1816 | } |
| 1817 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1818 | static bool ath9k_hw_chip_reset(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1819 | struct ath9k_channel *chan) |
| 1820 | { |
Vivek Natarajan | 42abfbe | 2009-09-17 09:27:59 +0530 | [diff] [blame] | 1821 | if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) { |
Senthil Balasubramanian | 8bd1d07 | 2009-02-12 13:57:03 +0530 | [diff] [blame] | 1822 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) |
| 1823 | return false; |
| 1824 | } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1825 | return false; |
| 1826 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 1827 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1828 | return false; |
| 1829 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1830 | ah->chip_fullsleep = false; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1831 | ath9k_hw_init_pll(ah, chan); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1832 | ath9k_hw_set_rfmode(ah, chan); |
| 1833 | |
| 1834 | return true; |
| 1835 | } |
| 1836 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1837 | static bool ath9k_hw_channel_change(struct ath_hw *ah, |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1838 | struct ath9k_channel *chan) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1839 | { |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 1840 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1841 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1842 | struct ieee80211_channel *channel = chan->chan; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1843 | u32 synthDelay, qnum; |
Luis R. Rodriguez | 0a3b7ba | 2009-10-19 02:33:40 -0400 | [diff] [blame] | 1844 | int r; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1845 | |
| 1846 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { |
| 1847 | if (ath9k_hw_numtxpending(ah, qnum)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1848 | ath_print(common, ATH_DBG_QUEUE, |
| 1849 | "Transmit frames pending on " |
| 1850 | "queue %d\n", qnum); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1851 | return false; |
| 1852 | } |
| 1853 | } |
| 1854 | |
| 1855 | REG_WRITE(ah, AR_PHY_RFBUS_REQ, AR_PHY_RFBUS_REQ_EN); |
| 1856 | if (!ath9k_hw_wait(ah, AR_PHY_RFBUS_GRANT, AR_PHY_RFBUS_GRANT_EN, |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1857 | AR_PHY_RFBUS_GRANT_EN, AH_WAIT_TIMEOUT)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1858 | ath_print(common, ATH_DBG_FATAL, |
| 1859 | "Could not kill baseband RX\n"); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1860 | return false; |
| 1861 | } |
| 1862 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1863 | ath9k_hw_set_regs(ah, chan); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1864 | |
Luis R. Rodriguez | e68a060 | 2009-10-19 02:33:41 -0400 | [diff] [blame] | 1865 | r = ah->ath9k_hw_rf_set_freq(ah, chan); |
Luis R. Rodriguez | 0a3b7ba | 2009-10-19 02:33:40 -0400 | [diff] [blame] | 1866 | if (r) { |
| 1867 | ath_print(common, ATH_DBG_FATAL, |
| 1868 | "Failed to set channel\n"); |
| 1869 | return false; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1870 | } |
| 1871 | |
Vasanthakumar Thiagarajan | 8fbff4b | 2009-05-08 17:54:51 -0700 | [diff] [blame] | 1872 | ah->eep_ops->set_txpower(ah, chan, |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 1873 | ath9k_regd_get_ctl(regulatory, chan), |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 1874 | channel->max_antenna_gain * 2, |
| 1875 | channel->max_power * 2, |
| 1876 | min((u32) MAX_RATE_POWER, |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 1877 | (u32) regulatory->power_limit)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1878 | |
| 1879 | synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY; |
Sujith | 788a3d6 | 2008-11-18 09:09:54 +0530 | [diff] [blame] | 1880 | if (IS_CHAN_B(chan)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1881 | synthDelay = (4 * synthDelay) / 22; |
| 1882 | else |
| 1883 | synthDelay /= 10; |
| 1884 | |
| 1885 | udelay(synthDelay + BASE_ACTIVATE_DELAY); |
| 1886 | |
| 1887 | REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0); |
| 1888 | |
| 1889 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) |
| 1890 | ath9k_hw_set_delta_slope(ah, chan); |
| 1891 | |
Luis R. Rodriguez | ae478cf | 2009-10-19 02:33:43 -0400 | [diff] [blame] | 1892 | ah->ath9k_hw_spur_mitigate_freq(ah, chan); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1893 | |
| 1894 | if (!chan->oneTimeCalsDone) |
| 1895 | chan->oneTimeCalsDone = true; |
| 1896 | |
| 1897 | return true; |
| 1898 | } |
| 1899 | |
Johannes Berg | 3b319aa | 2009-06-13 14:50:26 +0530 | [diff] [blame] | 1900 | static void ath9k_enable_rfkill(struct ath_hw *ah) |
| 1901 | { |
| 1902 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, |
| 1903 | AR_GPIO_INPUT_EN_VAL_RFSILENT_BB); |
| 1904 | |
| 1905 | REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2, |
| 1906 | AR_GPIO_INPUT_MUX2_RFSILENT); |
| 1907 | |
| 1908 | ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio); |
| 1909 | REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB); |
| 1910 | } |
| 1911 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1912 | int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1913 | bool bChannelChange) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1914 | { |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1915 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1916 | u32 saveLedState; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1917 | struct ath9k_channel *curchan = ah->curchan; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1918 | u32 saveDefAntenna; |
| 1919 | u32 macStaId1; |
Sujith | 46fe782 | 2009-09-17 09:25:25 +0530 | [diff] [blame] | 1920 | u64 tsf = 0; |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1921 | int i, rx_chainmask, r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1922 | |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 1923 | ah->txchainmask = common->tx_chainmask; |
| 1924 | ah->rxchainmask = common->rx_chainmask; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1925 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 1926 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1927 | return -EIO; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1928 | |
Vasanthakumar Thiagarajan | 9ebef799 | 2009-09-17 09:26:44 +0530 | [diff] [blame] | 1929 | if (curchan && !ah->chip_fullsleep) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1930 | ath9k_hw_getnf(ah, curchan); |
| 1931 | |
| 1932 | if (bChannelChange && |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1933 | (ah->chip_fullsleep != true) && |
| 1934 | (ah->curchan != NULL) && |
| 1935 | (chan->channel != ah->curchan->channel) && |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1936 | ((chan->channelFlags & CHANNEL_ALL) == |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1937 | (ah->curchan->channelFlags & CHANNEL_ALL)) && |
Vasanthakumar Thiagarajan | 0a475cc | 2009-09-17 09:27:10 +0530 | [diff] [blame] | 1938 | !(AR_SREV_9280(ah) || IS_CHAN_A_5MHZ_SPACED(chan) || |
| 1939 | IS_CHAN_A_5MHZ_SPACED(ah->curchan))) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1940 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1941 | if (ath9k_hw_channel_change(ah, chan)) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1942 | ath9k_hw_loadnf(ah, ah->curchan); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1943 | ath9k_hw_start_nfcal(ah); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1944 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1945 | } |
| 1946 | } |
| 1947 | |
| 1948 | saveDefAntenna = REG_READ(ah, AR_DEF_ANTENNA); |
| 1949 | if (saveDefAntenna == 0) |
| 1950 | saveDefAntenna = 1; |
| 1951 | |
| 1952 | macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B; |
| 1953 | |
Sujith | 46fe782 | 2009-09-17 09:25:25 +0530 | [diff] [blame] | 1954 | /* For chips on which RTC reset is done, save TSF before it gets cleared */ |
| 1955 | if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) |
| 1956 | tsf = ath9k_hw_gettsf64(ah); |
| 1957 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1958 | saveLedState = REG_READ(ah, AR_CFG_LED) & |
| 1959 | (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL | |
| 1960 | AR_CFG_LED_BLINK_THRESH_SEL | AR_CFG_LED_BLINK_SLOW); |
| 1961 | |
| 1962 | ath9k_hw_mark_phy_inactive(ah); |
| 1963 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1964 | if (AR_SREV_9271(ah) && ah->htc_reset_init) { |
| 1965 | REG_WRITE(ah, |
| 1966 | AR9271_RESET_POWER_DOWN_CONTROL, |
| 1967 | AR9271_RADIO_RF_RST); |
| 1968 | udelay(50); |
| 1969 | } |
| 1970 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1971 | if (!ath9k_hw_chip_reset(ah, chan)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1972 | ath_print(common, ATH_DBG_FATAL, "Chip reset failed\n"); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1973 | return -EINVAL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1974 | } |
| 1975 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 1976 | if (AR_SREV_9271(ah) && ah->htc_reset_init) { |
| 1977 | ah->htc_reset_init = false; |
| 1978 | REG_WRITE(ah, |
| 1979 | AR9271_RESET_POWER_DOWN_CONTROL, |
| 1980 | AR9271_GATE_MAC_CTL); |
| 1981 | udelay(50); |
| 1982 | } |
| 1983 | |
Sujith | 46fe782 | 2009-09-17 09:25:25 +0530 | [diff] [blame] | 1984 | /* Restore TSF */ |
| 1985 | if (tsf && AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) |
| 1986 | ath9k_hw_settsf64(ah, tsf); |
| 1987 | |
Vasanthakumar Thiagarajan | 369391d | 2009-01-21 19:24:13 +0530 | [diff] [blame] | 1988 | if (AR_SREV_9280_10_OR_LATER(ah)) |
| 1989 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1990 | |
Vivek Natarajan | 326bebb | 2009-08-14 11:33:36 +0530 | [diff] [blame] | 1991 | if (AR_SREV_9287_12_OR_LATER(ah)) { |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 1992 | /* Enable ASYNC FIFO */ |
| 1993 | REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, |
| 1994 | AR_MAC_PCU_ASYNC_FIFO_REG3_DATAPATH_SEL); |
| 1995 | REG_SET_BIT(ah, AR_PHY_MODE, AR_PHY_MODE_ASYNCFIFO); |
| 1996 | REG_CLR_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, |
| 1997 | AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET); |
| 1998 | REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, |
| 1999 | AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET); |
| 2000 | } |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 2001 | r = ath9k_hw_process_ini(ah, chan); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 2002 | if (r) |
| 2003 | return r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2004 | |
Jouni Malinen | 0ced0e1 | 2009-01-08 13:32:13 +0200 | [diff] [blame] | 2005 | /* Setup MFP options for CCMP */ |
| 2006 | if (AR_SREV_9280_20_OR_LATER(ah)) { |
| 2007 | /* Mask Retry(b11), PwrMgt(b12), MoreData(b13) to 0 in mgmt |
| 2008 | * frames when constructing CCMP AAD. */ |
| 2009 | REG_RMW_FIELD(ah, AR_AES_MUTE_MASK1, AR_AES_MUTE_MASK1_FC_MGMT, |
| 2010 | 0xc7ff); |
| 2011 | ah->sw_mgmt_crypto = false; |
| 2012 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { |
| 2013 | /* Disable hardware crypto for management frames */ |
| 2014 | REG_CLR_BIT(ah, AR_PCU_MISC_MODE2, |
| 2015 | AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE); |
| 2016 | REG_SET_BIT(ah, AR_PCU_MISC_MODE2, |
| 2017 | AR_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT); |
| 2018 | ah->sw_mgmt_crypto = true; |
| 2019 | } else |
| 2020 | ah->sw_mgmt_crypto = true; |
| 2021 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2022 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) |
| 2023 | ath9k_hw_set_delta_slope(ah, chan); |
| 2024 | |
Luis R. Rodriguez | ae478cf | 2009-10-19 02:33:43 -0400 | [diff] [blame] | 2025 | ah->ath9k_hw_spur_mitigate_freq(ah, chan); |
Sujith | d650915 | 2009-03-13 08:56:05 +0530 | [diff] [blame] | 2026 | ah->eep_ops->set_board_values(ah, chan); |
Luis R. Rodriguez | a776582 | 2009-10-19 02:33:45 -0400 | [diff] [blame] | 2027 | |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 2028 | REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr)); |
| 2029 | REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2030 | | macStaId1 |
| 2031 | | AR_STA_ID1_RTS_USE_DEF |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2032 | | (ah->config. |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 2033 | ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2034 | | ah->sta_id1_defaults); |
| 2035 | ath9k_hw_set_operating_mode(ah, ah->opmode); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2036 | |
Luis R. Rodriguez | 13b8155 | 2009-09-10 17:52:45 -0700 | [diff] [blame] | 2037 | ath_hw_setbssidmask(common); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2038 | |
| 2039 | REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna); |
| 2040 | |
Luis R. Rodriguez | 3453ad8 | 2009-09-10 08:57:00 -0700 | [diff] [blame] | 2041 | ath9k_hw_write_associd(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2042 | |
| 2043 | REG_WRITE(ah, AR_ISR, ~0); |
| 2044 | |
| 2045 | REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); |
| 2046 | |
Luis R. Rodriguez | e68a060 | 2009-10-19 02:33:41 -0400 | [diff] [blame] | 2047 | r = ah->ath9k_hw_rf_set_freq(ah, chan); |
Luis R. Rodriguez | 0a3b7ba | 2009-10-19 02:33:40 -0400 | [diff] [blame] | 2048 | if (r) |
| 2049 | return r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2050 | |
| 2051 | for (i = 0; i < AR_NUM_DCU; i++) |
| 2052 | REG_WRITE(ah, AR_DQCUMASK(i), 1 << i); |
| 2053 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2054 | ah->intr_txqs = 0; |
| 2055 | for (i = 0; i < ah->caps.total_queues; i++) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2056 | ath9k_hw_resettxqueue(ah, i); |
| 2057 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2058 | ath9k_hw_init_interrupt_masks(ah, ah->opmode); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2059 | ath9k_hw_init_qos(ah); |
| 2060 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2061 | if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 2062 | ath9k_enable_rfkill(ah); |
Johannes Berg | 3b319aa | 2009-06-13 14:50:26 +0530 | [diff] [blame] | 2063 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2064 | ath9k_hw_init_user_settings(ah); |
| 2065 | |
Vivek Natarajan | 326bebb | 2009-08-14 11:33:36 +0530 | [diff] [blame] | 2066 | if (AR_SREV_9287_12_OR_LATER(ah)) { |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 2067 | REG_WRITE(ah, AR_D_GBL_IFS_SIFS, |
| 2068 | AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR); |
| 2069 | REG_WRITE(ah, AR_D_GBL_IFS_SLOT, |
| 2070 | AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR); |
| 2071 | REG_WRITE(ah, AR_D_GBL_IFS_EIFS, |
| 2072 | AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR); |
| 2073 | |
| 2074 | REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR); |
| 2075 | REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR); |
| 2076 | |
| 2077 | REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER, |
| 2078 | AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768); |
| 2079 | REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN, |
| 2080 | AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL); |
| 2081 | } |
Vivek Natarajan | 326bebb | 2009-08-14 11:33:36 +0530 | [diff] [blame] | 2082 | if (AR_SREV_9287_12_OR_LATER(ah)) { |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 2083 | REG_SET_BIT(ah, AR_PCU_MISC_MODE2, |
| 2084 | AR_PCU_MISC_MODE2_ENABLE_AGGWEP); |
| 2085 | } |
| 2086 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2087 | REG_WRITE(ah, AR_STA_ID1, |
| 2088 | REG_READ(ah, AR_STA_ID1) | AR_STA_ID1_PRESERVE_SEQNUM); |
| 2089 | |
| 2090 | ath9k_hw_set_dma(ah); |
| 2091 | |
| 2092 | REG_WRITE(ah, AR_OBS, 8); |
| 2093 | |
Sujith | 0ce024c | 2009-12-14 14:57:00 +0530 | [diff] [blame^] | 2094 | if (ah->config.rx_intr_mitigation) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2095 | REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500); |
| 2096 | REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000); |
| 2097 | } |
| 2098 | |
| 2099 | ath9k_hw_init_bb(ah, chan); |
| 2100 | |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 2101 | if (!ath9k_hw_init_cal(ah, chan)) |
Joe Perches | 6badaaf | 2009-06-28 09:26:32 -0700 | [diff] [blame] | 2102 | return -EIO; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2103 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2104 | rx_chainmask = ah->rxchainmask; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2105 | if ((rx_chainmask == 0x5) || (rx_chainmask == 0x3)) { |
| 2106 | REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx_chainmask); |
| 2107 | REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx_chainmask); |
| 2108 | } |
| 2109 | |
| 2110 | REG_WRITE(ah, AR_CFG_LED, saveLedState | AR_CFG_SCLK_32KHZ); |
| 2111 | |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 2112 | /* |
| 2113 | * For big endian systems turn on swapping for descriptors |
| 2114 | */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2115 | if (AR_SREV_9100(ah)) { |
| 2116 | u32 mask; |
| 2117 | mask = REG_READ(ah, AR_CFG); |
| 2118 | if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2119 | ath_print(common, ATH_DBG_RESET, |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 2120 | "CFG Byte Swap Set 0x%x\n", mask); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2121 | } else { |
| 2122 | mask = |
| 2123 | INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB; |
| 2124 | REG_WRITE(ah, AR_CFG, mask); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2125 | ath_print(common, ATH_DBG_RESET, |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 2126 | "Setting CFG 0x%x\n", REG_READ(ah, AR_CFG)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2127 | } |
| 2128 | } else { |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 2129 | /* Configure AR9271 target WLAN */ |
| 2130 | if (AR_SREV_9271(ah)) |
| 2131 | REG_WRITE(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2132 | #ifdef __BIG_ENDIAN |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 2133 | else |
| 2134 | REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2135 | #endif |
| 2136 | } |
| 2137 | |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 2138 | if (ah->btcoex_hw.enabled) |
Vasanthakumar Thiagarajan | 42cc41e | 2009-08-26 21:08:45 +0530 | [diff] [blame] | 2139 | ath9k_hw_btcoex_enable(ah); |
| 2140 | |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 2141 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2142 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2143 | EXPORT_SYMBOL(ath9k_hw_reset); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2144 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2145 | /************************/ |
| 2146 | /* Key Cache Management */ |
| 2147 | /************************/ |
| 2148 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2149 | bool ath9k_hw_keyreset(struct ath_hw *ah, u16 entry) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2150 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2151 | u32 keyType; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2152 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2153 | if (entry >= ah->caps.keycache_size) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2154 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 2155 | "keychache entry %u out of range\n", entry); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2156 | return false; |
| 2157 | } |
| 2158 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2159 | keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2160 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2161 | REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0); |
| 2162 | REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0); |
| 2163 | REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0); |
| 2164 | REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0); |
| 2165 | REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0); |
| 2166 | REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR); |
| 2167 | REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0); |
| 2168 | REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0); |
| 2169 | |
| 2170 | if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) { |
| 2171 | u16 micentry = entry + 64; |
| 2172 | |
| 2173 | REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0); |
| 2174 | REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0); |
| 2175 | REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0); |
| 2176 | REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0); |
| 2177 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2178 | } |
| 2179 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2180 | return true; |
| 2181 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2182 | EXPORT_SYMBOL(ath9k_hw_keyreset); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2183 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2184 | bool ath9k_hw_keysetmac(struct ath_hw *ah, u16 entry, const u8 *mac) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2185 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2186 | u32 macHi, macLo; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2187 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2188 | if (entry >= ah->caps.keycache_size) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2189 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 2190 | "keychache entry %u out of range\n", entry); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2191 | return false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2192 | } |
| 2193 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2194 | if (mac != NULL) { |
| 2195 | macHi = (mac[5] << 8) | mac[4]; |
| 2196 | macLo = (mac[3] << 24) | |
| 2197 | (mac[2] << 16) | |
| 2198 | (mac[1] << 8) | |
| 2199 | mac[0]; |
| 2200 | macLo >>= 1; |
| 2201 | macLo |= (macHi & 1) << 31; |
| 2202 | macHi >>= 1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2203 | } else { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2204 | macLo = macHi = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2205 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2206 | REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), macLo); |
| 2207 | REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), macHi | AR_KEYTABLE_VALID); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2208 | |
| 2209 | return true; |
| 2210 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2211 | EXPORT_SYMBOL(ath9k_hw_keysetmac); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2212 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2213 | bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2214 | const struct ath9k_keyval *k, |
Jouni Malinen | e0caf9e | 2009-03-02 18:15:53 +0200 | [diff] [blame] | 2215 | const u8 *mac) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2216 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2217 | const struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2218 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2219 | u32 key0, key1, key2, key3, key4; |
| 2220 | u32 keyType; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2221 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2222 | if (entry >= pCap->keycache_size) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2223 | ath_print(common, ATH_DBG_FATAL, |
| 2224 | "keycache entry %u out of range\n", entry); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2225 | return false; |
| 2226 | } |
| 2227 | |
| 2228 | switch (k->kv_type) { |
| 2229 | case ATH9K_CIPHER_AES_OCB: |
| 2230 | keyType = AR_KEYTABLE_TYPE_AES; |
| 2231 | break; |
| 2232 | case ATH9K_CIPHER_AES_CCM: |
| 2233 | if (!(pCap->hw_caps & ATH9K_HW_CAP_CIPHER_AESCCM)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2234 | ath_print(common, ATH_DBG_ANY, |
| 2235 | "AES-CCM not supported by mac rev 0x%x\n", |
| 2236 | ah->hw_version.macRev); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2237 | return false; |
| 2238 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2239 | keyType = AR_KEYTABLE_TYPE_CCM; |
| 2240 | break; |
| 2241 | case ATH9K_CIPHER_TKIP: |
| 2242 | keyType = AR_KEYTABLE_TYPE_TKIP; |
| 2243 | if (ATH9K_IS_MIC_ENABLED(ah) |
| 2244 | && entry + 64 >= pCap->keycache_size) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2245 | ath_print(common, ATH_DBG_ANY, |
| 2246 | "entry %u inappropriate for TKIP\n", entry); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2247 | return false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2248 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2249 | break; |
| 2250 | case ATH9K_CIPHER_WEP: |
Zhu Yi | e31a16d | 2009-05-21 21:47:03 +0800 | [diff] [blame] | 2251 | if (k->kv_len < WLAN_KEY_LEN_WEP40) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2252 | ath_print(common, ATH_DBG_ANY, |
| 2253 | "WEP key length %u too small\n", k->kv_len); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2254 | return false; |
| 2255 | } |
Zhu Yi | e31a16d | 2009-05-21 21:47:03 +0800 | [diff] [blame] | 2256 | if (k->kv_len <= WLAN_KEY_LEN_WEP40) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2257 | keyType = AR_KEYTABLE_TYPE_40; |
Zhu Yi | e31a16d | 2009-05-21 21:47:03 +0800 | [diff] [blame] | 2258 | else if (k->kv_len <= WLAN_KEY_LEN_WEP104) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2259 | keyType = AR_KEYTABLE_TYPE_104; |
| 2260 | else |
| 2261 | keyType = AR_KEYTABLE_TYPE_128; |
| 2262 | break; |
| 2263 | case ATH9K_CIPHER_CLR: |
| 2264 | keyType = AR_KEYTABLE_TYPE_CLR; |
| 2265 | break; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2266 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2267 | ath_print(common, ATH_DBG_FATAL, |
| 2268 | "cipher %u not supported\n", k->kv_type); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2269 | return false; |
| 2270 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2271 | |
Jouni Malinen | e0caf9e | 2009-03-02 18:15:53 +0200 | [diff] [blame] | 2272 | key0 = get_unaligned_le32(k->kv_val + 0); |
| 2273 | key1 = get_unaligned_le16(k->kv_val + 4); |
| 2274 | key2 = get_unaligned_le32(k->kv_val + 6); |
| 2275 | key3 = get_unaligned_le16(k->kv_val + 10); |
| 2276 | key4 = get_unaligned_le32(k->kv_val + 12); |
Zhu Yi | e31a16d | 2009-05-21 21:47:03 +0800 | [diff] [blame] | 2277 | if (k->kv_len <= WLAN_KEY_LEN_WEP104) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2278 | key4 &= 0xff; |
| 2279 | |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2280 | /* |
| 2281 | * Note: Key cache registers access special memory area that requires |
| 2282 | * two 32-bit writes to actually update the values in the internal |
| 2283 | * memory. Consequently, the exact order and pairs used here must be |
| 2284 | * maintained. |
| 2285 | */ |
| 2286 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2287 | if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) { |
| 2288 | u16 micentry = entry + 64; |
| 2289 | |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2290 | /* |
| 2291 | * Write inverted key[47:0] first to avoid Michael MIC errors |
| 2292 | * on frames that could be sent or received at the same time. |
| 2293 | * The correct key will be written in the end once everything |
| 2294 | * else is ready. |
| 2295 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2296 | REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), ~key0); |
| 2297 | REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), ~key1); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2298 | |
| 2299 | /* Write key[95:48] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2300 | REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2); |
| 2301 | REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2302 | |
| 2303 | /* Write key[127:96] and key type */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2304 | REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4); |
| 2305 | REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2306 | |
| 2307 | /* Write MAC address for the entry */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2308 | (void) ath9k_hw_keysetmac(ah, entry, mac); |
| 2309 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2310 | if (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) { |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2311 | /* |
| 2312 | * TKIP uses two key cache entries: |
| 2313 | * Michael MIC TX/RX keys in the same key cache entry |
| 2314 | * (idx = main index + 64): |
| 2315 | * key0 [31:0] = RX key [31:0] |
| 2316 | * key1 [15:0] = TX key [31:16] |
| 2317 | * key1 [31:16] = reserved |
| 2318 | * key2 [31:0] = RX key [63:32] |
| 2319 | * key3 [15:0] = TX key [15:0] |
| 2320 | * key3 [31:16] = reserved |
| 2321 | * key4 [31:0] = TX key [63:32] |
| 2322 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2323 | u32 mic0, mic1, mic2, mic3, mic4; |
| 2324 | |
| 2325 | mic0 = get_unaligned_le32(k->kv_mic + 0); |
| 2326 | mic2 = get_unaligned_le32(k->kv_mic + 4); |
| 2327 | mic1 = get_unaligned_le16(k->kv_txmic + 2) & 0xffff; |
| 2328 | mic3 = get_unaligned_le16(k->kv_txmic + 0) & 0xffff; |
| 2329 | mic4 = get_unaligned_le32(k->kv_txmic + 4); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2330 | |
| 2331 | /* Write RX[31:0] and TX[31:16] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2332 | REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0); |
| 2333 | REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), mic1); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2334 | |
| 2335 | /* Write RX[63:32] and TX[15:0] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2336 | REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2); |
| 2337 | REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), mic3); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2338 | |
| 2339 | /* Write TX[63:32] and keyType(reserved) */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2340 | REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), mic4); |
| 2341 | REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry), |
| 2342 | AR_KEYTABLE_TYPE_CLR); |
| 2343 | |
| 2344 | } else { |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2345 | /* |
| 2346 | * TKIP uses four key cache entries (two for group |
| 2347 | * keys): |
| 2348 | * Michael MIC TX/RX keys are in different key cache |
| 2349 | * entries (idx = main index + 64 for TX and |
| 2350 | * main index + 32 + 96 for RX): |
| 2351 | * key0 [31:0] = TX/RX MIC key [31:0] |
| 2352 | * key1 [31:0] = reserved |
| 2353 | * key2 [31:0] = TX/RX MIC key [63:32] |
| 2354 | * key3 [31:0] = reserved |
| 2355 | * key4 [31:0] = reserved |
| 2356 | * |
| 2357 | * Upper layer code will call this function separately |
| 2358 | * for TX and RX keys when these registers offsets are |
| 2359 | * used. |
| 2360 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2361 | u32 mic0, mic2; |
| 2362 | |
| 2363 | mic0 = get_unaligned_le32(k->kv_mic + 0); |
| 2364 | mic2 = get_unaligned_le32(k->kv_mic + 4); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2365 | |
| 2366 | /* Write MIC key[31:0] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2367 | REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0); |
| 2368 | REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2369 | |
| 2370 | /* Write MIC key[63:32] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2371 | REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2); |
| 2372 | REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2373 | |
| 2374 | /* Write TX[63:32] and keyType(reserved) */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2375 | REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0); |
| 2376 | REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry), |
| 2377 | AR_KEYTABLE_TYPE_CLR); |
| 2378 | } |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2379 | |
| 2380 | /* MAC address registers are reserved for the MIC entry */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2381 | REG_WRITE(ah, AR_KEYTABLE_MAC0(micentry), 0); |
| 2382 | REG_WRITE(ah, AR_KEYTABLE_MAC1(micentry), 0); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2383 | |
| 2384 | /* |
| 2385 | * Write the correct (un-inverted) key[47:0] last to enable |
| 2386 | * TKIP now that all other registers are set with correct |
| 2387 | * values. |
| 2388 | */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2389 | REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0); |
| 2390 | REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1); |
| 2391 | } else { |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2392 | /* Write key[47:0] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2393 | REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0); |
| 2394 | REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2395 | |
| 2396 | /* Write key[95:48] */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2397 | REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2); |
| 2398 | REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3); |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2399 | |
| 2400 | /* Write key[127:96] and key type */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2401 | REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4); |
| 2402 | REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType); |
| 2403 | |
Jouni Malinen | 672903b | 2009-03-02 15:06:31 +0200 | [diff] [blame] | 2404 | /* Write MAC address for the entry */ |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2405 | (void) ath9k_hw_keysetmac(ah, entry, mac); |
| 2406 | } |
| 2407 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2408 | return true; |
| 2409 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2410 | EXPORT_SYMBOL(ath9k_hw_set_keycache_entry); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2411 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2412 | bool ath9k_hw_keyisvalid(struct ath_hw *ah, u16 entry) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2413 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2414 | if (entry < ah->caps.keycache_size) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2415 | u32 val = REG_READ(ah, AR_KEYTABLE_MAC1(entry)); |
| 2416 | if (val & AR_KEYTABLE_VALID) |
| 2417 | return true; |
| 2418 | } |
| 2419 | return false; |
| 2420 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2421 | EXPORT_SYMBOL(ath9k_hw_keyisvalid); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2422 | |
| 2423 | /******************************/ |
| 2424 | /* Power Management (Chipset) */ |
| 2425 | /******************************/ |
| 2426 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2427 | static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2428 | { |
| 2429 | REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); |
| 2430 | if (setChip) { |
| 2431 | REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, |
| 2432 | AR_RTC_FORCE_WAKE_EN); |
| 2433 | if (!AR_SREV_9100(ah)) |
| 2434 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); |
| 2435 | |
Sujith | 4921be8 | 2009-09-18 15:04:27 +0530 | [diff] [blame] | 2436 | if(!AR_SREV_5416(ah)) |
| 2437 | REG_CLR_BIT(ah, (AR_RTC_RESET), |
| 2438 | AR_RTC_RESET_EN); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2439 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2440 | } |
| 2441 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2442 | static void ath9k_set_power_network_sleep(struct ath_hw *ah, int setChip) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2443 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2444 | REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); |
| 2445 | if (setChip) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2446 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2447 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2448 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
| 2449 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, |
| 2450 | AR_RTC_FORCE_WAKE_ON_INT); |
| 2451 | } else { |
| 2452 | REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, |
| 2453 | AR_RTC_FORCE_WAKE_EN); |
| 2454 | } |
| 2455 | } |
| 2456 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2457 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2458 | static bool ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2459 | { |
| 2460 | u32 val; |
| 2461 | int i; |
| 2462 | |
| 2463 | if (setChip) { |
| 2464 | if ((REG_READ(ah, AR_RTC_STATUS) & |
| 2465 | AR_RTC_STATUS_M) == AR_RTC_STATUS_SHUTDOWN) { |
| 2466 | if (ath9k_hw_set_reset_reg(ah, |
| 2467 | ATH9K_RESET_POWER_ON) != true) { |
| 2468 | return false; |
| 2469 | } |
Senthil Balasubramanian | 63a75b9 | 2009-09-18 15:07:03 +0530 | [diff] [blame] | 2470 | ath9k_hw_init_pll(ah, NULL); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2471 | } |
| 2472 | if (AR_SREV_9100(ah)) |
| 2473 | REG_SET_BIT(ah, AR_RTC_RESET, |
| 2474 | AR_RTC_RESET_EN); |
| 2475 | |
| 2476 | REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, |
| 2477 | AR_RTC_FORCE_WAKE_EN); |
| 2478 | udelay(50); |
| 2479 | |
| 2480 | for (i = POWER_UP_TIME / 50; i > 0; i--) { |
| 2481 | val = REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M; |
| 2482 | if (val == AR_RTC_STATUS_ON) |
| 2483 | break; |
| 2484 | udelay(50); |
| 2485 | REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, |
| 2486 | AR_RTC_FORCE_WAKE_EN); |
| 2487 | } |
| 2488 | if (i == 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2489 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 2490 | "Failed to wakeup in %uus\n", |
| 2491 | POWER_UP_TIME / 20); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2492 | return false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2493 | } |
| 2494 | } |
| 2495 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2496 | REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); |
| 2497 | |
| 2498 | return true; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2499 | } |
| 2500 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 2501 | bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2502 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2503 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2504 | int status = true, setChip = true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2505 | static const char *modes[] = { |
| 2506 | "AWAKE", |
| 2507 | "FULL-SLEEP", |
| 2508 | "NETWORK SLEEP", |
| 2509 | "UNDEFINED" |
| 2510 | }; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2511 | |
Gabor Juhos | cbdec97 | 2009-07-24 17:27:22 +0200 | [diff] [blame] | 2512 | if (ah->power_mode == mode) |
| 2513 | return status; |
| 2514 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2515 | ath_print(common, ATH_DBG_RESET, "%s -> %s\n", |
| 2516 | modes[ah->power_mode], modes[mode]); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2517 | |
| 2518 | switch (mode) { |
| 2519 | case ATH9K_PM_AWAKE: |
| 2520 | status = ath9k_hw_set_power_awake(ah, setChip); |
| 2521 | break; |
| 2522 | case ATH9K_PM_FULL_SLEEP: |
| 2523 | ath9k_set_power_sleep(ah, setChip); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2524 | ah->chip_fullsleep = true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2525 | break; |
| 2526 | case ATH9K_PM_NETWORK_SLEEP: |
| 2527 | ath9k_set_power_network_sleep(ah, setChip); |
| 2528 | break; |
| 2529 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2530 | ath_print(common, ATH_DBG_FATAL, |
| 2531 | "Unknown power mode %u\n", mode); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2532 | return false; |
| 2533 | } |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2534 | ah->power_mode = mode; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2535 | |
| 2536 | return status; |
| 2537 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2538 | EXPORT_SYMBOL(ath9k_hw_setpower); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2539 | |
Luis R. Rodriguez | 24c1a28 | 2009-02-10 15:35:22 -0800 | [diff] [blame] | 2540 | /* |
| 2541 | * Helper for ASPM support. |
| 2542 | * |
| 2543 | * Disable PLL when in L0s as well as receiver clock when in L1. |
| 2544 | * This power saving option must be enabled through the SerDes. |
| 2545 | * |
| 2546 | * Programming the SerDes must go through the same 288 bit serial shift |
| 2547 | * register as the other analog registers. Hence the 9 writes. |
| 2548 | */ |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2549 | void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2550 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2551 | u8 i; |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2552 | u32 val; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2553 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2554 | if (ah->is_pciexpress != true) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2555 | return; |
| 2556 | |
Luis R. Rodriguez | 24c1a28 | 2009-02-10 15:35:22 -0800 | [diff] [blame] | 2557 | /* Do not touch SerDes registers */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2558 | if (ah->config.pcie_powersave_enable == 2) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2559 | return; |
| 2560 | |
Luis R. Rodriguez | 24c1a28 | 2009-02-10 15:35:22 -0800 | [diff] [blame] | 2561 | /* Nothing to do on restore for 11N */ |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2562 | if (!restore) { |
| 2563 | if (AR_SREV_9280_20_OR_LATER(ah)) { |
| 2564 | /* |
| 2565 | * AR9280 2.0 or later chips use SerDes values from the |
| 2566 | * initvals.h initialized depending on chipset during |
| 2567 | * ath9k_hw_init() |
| 2568 | */ |
| 2569 | for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) { |
| 2570 | REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0), |
| 2571 | INI_RA(&ah->iniPcieSerdes, i, 1)); |
| 2572 | } |
| 2573 | } else if (AR_SREV_9280(ah) && |
| 2574 | (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) { |
| 2575 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00); |
| 2576 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2577 | |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2578 | /* RX shut off when elecidle is asserted */ |
| 2579 | REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019); |
| 2580 | REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820); |
| 2581 | REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560); |
| 2582 | |
| 2583 | /* Shut off CLKREQ active in L1 */ |
| 2584 | if (ah->config.pcie_clock_req) |
| 2585 | REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc); |
| 2586 | else |
| 2587 | REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd); |
| 2588 | |
| 2589 | REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); |
| 2590 | REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); |
| 2591 | REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007); |
| 2592 | |
| 2593 | /* Load the new settings */ |
| 2594 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); |
| 2595 | |
| 2596 | } else { |
| 2597 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); |
| 2598 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); |
| 2599 | |
| 2600 | /* RX shut off when elecidle is asserted */ |
| 2601 | REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039); |
| 2602 | REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824); |
| 2603 | REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579); |
| 2604 | |
| 2605 | /* |
| 2606 | * Ignore ah->ah_config.pcie_clock_req setting for |
| 2607 | * pre-AR9280 11n |
| 2608 | */ |
| 2609 | REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff); |
| 2610 | |
| 2611 | REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); |
| 2612 | REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); |
| 2613 | REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007); |
| 2614 | |
| 2615 | /* Load the new settings */ |
| 2616 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2617 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2618 | |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2619 | udelay(1000); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2620 | |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2621 | /* set bit 19 to allow forcing of pcie core into L1 state */ |
| 2622 | REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2623 | |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2624 | /* Several PCIe massages to ensure proper behaviour */ |
| 2625 | if (ah->config.pcie_waen) { |
| 2626 | val = ah->config.pcie_waen; |
| 2627 | if (!power_off) |
| 2628 | val &= (~AR_WA_D3_L1_DISABLE); |
| 2629 | } else { |
| 2630 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || |
| 2631 | AR_SREV_9287(ah)) { |
| 2632 | val = AR9285_WA_DEFAULT; |
| 2633 | if (!power_off) |
| 2634 | val &= (~AR_WA_D3_L1_DISABLE); |
| 2635 | } else if (AR_SREV_9280(ah)) { |
| 2636 | /* |
| 2637 | * On AR9280 chips bit 22 of 0x4004 needs to be |
| 2638 | * set otherwise card may disappear. |
| 2639 | */ |
| 2640 | val = AR9280_WA_DEFAULT; |
| 2641 | if (!power_off) |
| 2642 | val &= (~AR_WA_D3_L1_DISABLE); |
| 2643 | } else |
| 2644 | val = AR_WA_DEFAULT; |
| 2645 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2646 | |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2647 | REG_WRITE(ah, AR_WA, val); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2648 | } |
| 2649 | |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2650 | if (power_off) { |
Luis R. Rodriguez | 24c1a28 | 2009-02-10 15:35:22 -0800 | [diff] [blame] | 2651 | /* |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2652 | * Set PCIe workaround bits |
| 2653 | * bit 14 in WA register (disable L1) should only |
| 2654 | * be set when device enters D3 and be cleared |
| 2655 | * when device comes back to D0. |
Luis R. Rodriguez | 24c1a28 | 2009-02-10 15:35:22 -0800 | [diff] [blame] | 2656 | */ |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 2657 | if (ah->config.pcie_waen) { |
| 2658 | if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE) |
| 2659 | REG_SET_BIT(ah, AR_WA, AR_WA_D3_L1_DISABLE); |
| 2660 | } else { |
| 2661 | if (((AR_SREV_9285(ah) || AR_SREV_9271(ah) || |
| 2662 | AR_SREV_9287(ah)) && |
| 2663 | (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) || |
| 2664 | (AR_SREV_9280(ah) && |
| 2665 | (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) { |
| 2666 | REG_SET_BIT(ah, AR_WA, AR_WA_D3_L1_DISABLE); |
| 2667 | } |
| 2668 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2669 | } |
| 2670 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2671 | EXPORT_SYMBOL(ath9k_hw_configpcipowersave); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2672 | |
| 2673 | /**********************/ |
| 2674 | /* Interrupt Handling */ |
| 2675 | /**********************/ |
| 2676 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2677 | bool ath9k_hw_intrpend(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2678 | { |
| 2679 | u32 host_isr; |
| 2680 | |
| 2681 | if (AR_SREV_9100(ah)) |
| 2682 | return true; |
| 2683 | |
| 2684 | host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE); |
| 2685 | if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS)) |
| 2686 | return true; |
| 2687 | |
| 2688 | host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE); |
| 2689 | if ((host_isr & AR_INTR_SYNC_DEFAULT) |
| 2690 | && (host_isr != AR_INTR_SPURIOUS)) |
| 2691 | return true; |
| 2692 | |
| 2693 | return false; |
| 2694 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2695 | EXPORT_SYMBOL(ath9k_hw_intrpend); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2696 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2697 | bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2698 | { |
| 2699 | u32 isr = 0; |
| 2700 | u32 mask2 = 0; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2701 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2702 | u32 sync_cause = 0; |
| 2703 | bool fatal_int = false; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2704 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2705 | |
| 2706 | if (!AR_SREV_9100(ah)) { |
| 2707 | if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) { |
| 2708 | if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) |
| 2709 | == AR_RTC_STATUS_ON) { |
| 2710 | isr = REG_READ(ah, AR_ISR); |
| 2711 | } |
| 2712 | } |
| 2713 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2714 | sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) & |
| 2715 | AR_INTR_SYNC_DEFAULT; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2716 | |
| 2717 | *masked = 0; |
| 2718 | |
| 2719 | if (!isr && !sync_cause) |
| 2720 | return false; |
| 2721 | } else { |
| 2722 | *masked = 0; |
| 2723 | isr = REG_READ(ah, AR_ISR); |
| 2724 | } |
| 2725 | |
| 2726 | if (isr) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2727 | if (isr & AR_ISR_BCNMISC) { |
| 2728 | u32 isr2; |
| 2729 | isr2 = REG_READ(ah, AR_ISR_S2); |
| 2730 | if (isr2 & AR_ISR_S2_TIM) |
| 2731 | mask2 |= ATH9K_INT_TIM; |
| 2732 | if (isr2 & AR_ISR_S2_DTIM) |
| 2733 | mask2 |= ATH9K_INT_DTIM; |
| 2734 | if (isr2 & AR_ISR_S2_DTIMSYNC) |
| 2735 | mask2 |= ATH9K_INT_DTIMSYNC; |
| 2736 | if (isr2 & (AR_ISR_S2_CABEND)) |
| 2737 | mask2 |= ATH9K_INT_CABEND; |
| 2738 | if (isr2 & AR_ISR_S2_GTT) |
| 2739 | mask2 |= ATH9K_INT_GTT; |
| 2740 | if (isr2 & AR_ISR_S2_CST) |
| 2741 | mask2 |= ATH9K_INT_CST; |
Sujith | 4af9cf4 | 2009-02-12 10:06:47 +0530 | [diff] [blame] | 2742 | if (isr2 & AR_ISR_S2_TSFOOR) |
| 2743 | mask2 |= ATH9K_INT_TSFOOR; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2744 | } |
| 2745 | |
| 2746 | isr = REG_READ(ah, AR_ISR_RAC); |
| 2747 | if (isr == 0xffffffff) { |
| 2748 | *masked = 0; |
| 2749 | return false; |
| 2750 | } |
| 2751 | |
| 2752 | *masked = isr & ATH9K_INT_COMMON; |
| 2753 | |
Sujith | 0ce024c | 2009-12-14 14:57:00 +0530 | [diff] [blame^] | 2754 | if (ah->config.rx_intr_mitigation) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2755 | if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) |
| 2756 | *masked |= ATH9K_INT_RX; |
| 2757 | } |
| 2758 | |
| 2759 | if (isr & (AR_ISR_RXOK | AR_ISR_RXERR)) |
| 2760 | *masked |= ATH9K_INT_RX; |
| 2761 | if (isr & |
| 2762 | (AR_ISR_TXOK | AR_ISR_TXDESC | AR_ISR_TXERR | |
| 2763 | AR_ISR_TXEOL)) { |
| 2764 | u32 s0_s, s1_s; |
| 2765 | |
| 2766 | *masked |= ATH9K_INT_TX; |
| 2767 | |
| 2768 | s0_s = REG_READ(ah, AR_ISR_S0_S); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2769 | ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXOK); |
| 2770 | ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXDESC); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2771 | |
| 2772 | s1_s = REG_READ(ah, AR_ISR_S1_S); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2773 | ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXERR); |
| 2774 | ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXEOL); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2775 | } |
| 2776 | |
| 2777 | if (isr & AR_ISR_RXORN) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2778 | ath_print(common, ATH_DBG_INTERRUPT, |
| 2779 | "receive FIFO overrun interrupt\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2780 | } |
| 2781 | |
| 2782 | if (!AR_SREV_9100(ah)) { |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 2783 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2784 | u32 isr5 = REG_READ(ah, AR_ISR_S5_S); |
| 2785 | if (isr5 & AR_ISR_S5_TIM_TIMER) |
| 2786 | *masked |= ATH9K_INT_TIM_TIMER; |
| 2787 | } |
| 2788 | } |
| 2789 | |
| 2790 | *masked |= mask2; |
| 2791 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2792 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2793 | if (AR_SREV_9100(ah)) |
| 2794 | return true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2795 | |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 2796 | if (isr & AR_ISR_GENTMR) { |
| 2797 | u32 s5_s; |
| 2798 | |
| 2799 | s5_s = REG_READ(ah, AR_ISR_S5_S); |
| 2800 | if (isr & AR_ISR_GENTMR) { |
| 2801 | ah->intr_gen_timer_trigger = |
| 2802 | MS(s5_s, AR_ISR_S5_GENTIMER_TRIG); |
| 2803 | |
| 2804 | ah->intr_gen_timer_thresh = |
| 2805 | MS(s5_s, AR_ISR_S5_GENTIMER_THRESH); |
| 2806 | |
| 2807 | if (ah->intr_gen_timer_trigger) |
| 2808 | *masked |= ATH9K_INT_GENTIMER; |
| 2809 | |
| 2810 | } |
| 2811 | } |
| 2812 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2813 | if (sync_cause) { |
| 2814 | fatal_int = |
| 2815 | (sync_cause & |
| 2816 | (AR_INTR_SYNC_HOST1_FATAL | AR_INTR_SYNC_HOST1_PERR)) |
| 2817 | ? true : false; |
| 2818 | |
| 2819 | if (fatal_int) { |
| 2820 | if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2821 | ath_print(common, ATH_DBG_ANY, |
| 2822 | "received PCI FATAL interrupt\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2823 | } |
| 2824 | if (sync_cause & AR_INTR_SYNC_HOST1_PERR) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2825 | ath_print(common, ATH_DBG_ANY, |
| 2826 | "received PCI PERR interrupt\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2827 | } |
Steven Luo | a89bff9 | 2009-04-12 02:57:54 -0700 | [diff] [blame] | 2828 | *masked |= ATH9K_INT_FATAL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2829 | } |
| 2830 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2831 | ath_print(common, ATH_DBG_INTERRUPT, |
| 2832 | "AR_INTR_SYNC_RADM_CPL_TIMEOUT\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2833 | REG_WRITE(ah, AR_RC, AR_RC_HOSTIF); |
| 2834 | REG_WRITE(ah, AR_RC, 0); |
| 2835 | *masked |= ATH9K_INT_FATAL; |
| 2836 | } |
| 2837 | if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2838 | ath_print(common, ATH_DBG_INTERRUPT, |
| 2839 | "AR_INTR_SYNC_LOCAL_TIMEOUT\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2840 | } |
| 2841 | |
| 2842 | REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause); |
| 2843 | (void) REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR); |
| 2844 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2845 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2846 | return true; |
| 2847 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2848 | EXPORT_SYMBOL(ath9k_hw_getisr); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2849 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2850 | enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2851 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2852 | u32 omask = ah->mask_reg; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2853 | u32 mask, mask2; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2854 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2855 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2856 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2857 | ath_print(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2858 | |
| 2859 | if (omask & ATH9K_INT_GLOBAL) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2860 | ath_print(common, ATH_DBG_INTERRUPT, "disable IER\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2861 | REG_WRITE(ah, AR_IER, AR_IER_DISABLE); |
| 2862 | (void) REG_READ(ah, AR_IER); |
| 2863 | if (!AR_SREV_9100(ah)) { |
| 2864 | REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0); |
| 2865 | (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE); |
| 2866 | |
| 2867 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0); |
| 2868 | (void) REG_READ(ah, AR_INTR_SYNC_ENABLE); |
| 2869 | } |
| 2870 | } |
| 2871 | |
| 2872 | mask = ints & ATH9K_INT_COMMON; |
| 2873 | mask2 = 0; |
| 2874 | |
| 2875 | if (ints & ATH9K_INT_TX) { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2876 | if (ah->txok_interrupt_mask) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2877 | mask |= AR_IMR_TXOK; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2878 | if (ah->txdesc_interrupt_mask) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2879 | mask |= AR_IMR_TXDESC; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2880 | if (ah->txerr_interrupt_mask) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2881 | mask |= AR_IMR_TXERR; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2882 | if (ah->txeol_interrupt_mask) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2883 | mask |= AR_IMR_TXEOL; |
| 2884 | } |
| 2885 | if (ints & ATH9K_INT_RX) { |
| 2886 | mask |= AR_IMR_RXERR; |
Sujith | 0ce024c | 2009-12-14 14:57:00 +0530 | [diff] [blame^] | 2887 | if (ah->config.rx_intr_mitigation) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2888 | mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM; |
| 2889 | else |
| 2890 | mask |= AR_IMR_RXOK | AR_IMR_RXDESC; |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 2891 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2892 | mask |= AR_IMR_GENTMR; |
| 2893 | } |
| 2894 | |
| 2895 | if (ints & (ATH9K_INT_BMISC)) { |
| 2896 | mask |= AR_IMR_BCNMISC; |
| 2897 | if (ints & ATH9K_INT_TIM) |
| 2898 | mask2 |= AR_IMR_S2_TIM; |
| 2899 | if (ints & ATH9K_INT_DTIM) |
| 2900 | mask2 |= AR_IMR_S2_DTIM; |
| 2901 | if (ints & ATH9K_INT_DTIMSYNC) |
| 2902 | mask2 |= AR_IMR_S2_DTIMSYNC; |
| 2903 | if (ints & ATH9K_INT_CABEND) |
Sujith | 4af9cf4 | 2009-02-12 10:06:47 +0530 | [diff] [blame] | 2904 | mask2 |= AR_IMR_S2_CABEND; |
| 2905 | if (ints & ATH9K_INT_TSFOOR) |
| 2906 | mask2 |= AR_IMR_S2_TSFOOR; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2907 | } |
| 2908 | |
| 2909 | if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) { |
| 2910 | mask |= AR_IMR_BCNMISC; |
| 2911 | if (ints & ATH9K_INT_GTT) |
| 2912 | mask2 |= AR_IMR_S2_GTT; |
| 2913 | if (ints & ATH9K_INT_CST) |
| 2914 | mask2 |= AR_IMR_S2_CST; |
| 2915 | } |
| 2916 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2917 | ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2918 | REG_WRITE(ah, AR_IMR, mask); |
| 2919 | mask = REG_READ(ah, AR_IMR_S2) & ~(AR_IMR_S2_TIM | |
| 2920 | AR_IMR_S2_DTIM | |
| 2921 | AR_IMR_S2_DTIMSYNC | |
| 2922 | AR_IMR_S2_CABEND | |
| 2923 | AR_IMR_S2_CABTO | |
| 2924 | AR_IMR_S2_TSFOOR | |
| 2925 | AR_IMR_S2_GTT | AR_IMR_S2_CST); |
| 2926 | REG_WRITE(ah, AR_IMR_S2, mask | mask2); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2927 | ah->mask_reg = ints; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2928 | |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 2929 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2930 | if (ints & ATH9K_INT_TIM_TIMER) |
| 2931 | REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER); |
| 2932 | else |
| 2933 | REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER); |
| 2934 | } |
| 2935 | |
| 2936 | if (ints & ATH9K_INT_GLOBAL) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2937 | ath_print(common, ATH_DBG_INTERRUPT, "enable IER\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2938 | REG_WRITE(ah, AR_IER, AR_IER_ENABLE); |
| 2939 | if (!AR_SREV_9100(ah)) { |
| 2940 | REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, |
| 2941 | AR_INTR_MAC_IRQ); |
| 2942 | REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ); |
| 2943 | |
| 2944 | |
| 2945 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, |
| 2946 | AR_INTR_SYNC_DEFAULT); |
| 2947 | REG_WRITE(ah, AR_INTR_SYNC_MASK, |
| 2948 | AR_INTR_SYNC_DEFAULT); |
| 2949 | } |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2950 | ath_print(common, ATH_DBG_INTERRUPT, "AR_IMR 0x%x IER 0x%x\n", |
| 2951 | REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2952 | } |
| 2953 | |
| 2954 | return omask; |
| 2955 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 2956 | EXPORT_SYMBOL(ath9k_hw_set_interrupts); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2957 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 2958 | /*******************/ |
| 2959 | /* Beacon Handling */ |
| 2960 | /*******************/ |
| 2961 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 2962 | void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2963 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2964 | int flags = 0; |
| 2965 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2966 | ah->beacon_interval = beacon_period; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2967 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2968 | switch (ah->opmode) { |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 2969 | case NL80211_IFTYPE_STATION: |
| 2970 | case NL80211_IFTYPE_MONITOR: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2971 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(next_beacon)); |
| 2972 | REG_WRITE(ah, AR_NEXT_DMA_BEACON_ALERT, 0xffff); |
| 2973 | REG_WRITE(ah, AR_NEXT_SWBA, 0x7ffff); |
| 2974 | flags |= AR_TBTT_TIMER_EN; |
| 2975 | break; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 2976 | case NL80211_IFTYPE_ADHOC: |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 2977 | case NL80211_IFTYPE_MESH_POINT: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2978 | REG_SET_BIT(ah, AR_TXCFG, |
| 2979 | AR_TXCFG_ADHOC_BEACON_ATIM_TX_POLICY); |
| 2980 | REG_WRITE(ah, AR_NEXT_NDP_TIMER, |
| 2981 | TU_TO_USEC(next_beacon + |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2982 | (ah->atim_window ? ah-> |
| 2983 | atim_window : 1))); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2984 | flags |= AR_NDP_TIMER_EN; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 2985 | case NL80211_IFTYPE_AP: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2986 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(next_beacon)); |
| 2987 | REG_WRITE(ah, AR_NEXT_DMA_BEACON_ALERT, |
| 2988 | TU_TO_USEC(next_beacon - |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2989 | ah->config. |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 2990 | dma_beacon_response_time)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2991 | REG_WRITE(ah, AR_NEXT_SWBA, |
| 2992 | TU_TO_USEC(next_beacon - |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2993 | ah->config. |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 2994 | sw_beacon_response_time)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2995 | flags |= |
| 2996 | AR_TBTT_TIMER_EN | AR_DBA_TIMER_EN | AR_SWBA_TIMER_EN; |
| 2997 | break; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 2998 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2999 | ath_print(ath9k_hw_common(ah), ATH_DBG_BEACON, |
| 3000 | "%s: unsupported opmode: %d\n", |
| 3001 | __func__, ah->opmode); |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 3002 | return; |
| 3003 | break; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3004 | } |
| 3005 | |
| 3006 | REG_WRITE(ah, AR_BEACON_PERIOD, TU_TO_USEC(beacon_period)); |
| 3007 | REG_WRITE(ah, AR_DMA_BEACON_PERIOD, TU_TO_USEC(beacon_period)); |
| 3008 | REG_WRITE(ah, AR_SWBA_PERIOD, TU_TO_USEC(beacon_period)); |
| 3009 | REG_WRITE(ah, AR_NDP_PERIOD, TU_TO_USEC(beacon_period)); |
| 3010 | |
| 3011 | beacon_period &= ~ATH9K_BEACON_ENA; |
| 3012 | if (beacon_period & ATH9K_BEACON_RESET_TSF) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3013 | ath9k_hw_reset_tsf(ah); |
| 3014 | } |
| 3015 | |
| 3016 | REG_SET_BIT(ah, AR_TIMER_MODE, flags); |
| 3017 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3018 | EXPORT_SYMBOL(ath9k_hw_beaconinit); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3019 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3020 | void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3021 | const struct ath9k_beacon_state *bs) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3022 | { |
| 3023 | u32 nextTbtt, beaconintval, dtimperiod, beacontimeout; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3024 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3025 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3026 | |
| 3027 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bs->bs_nexttbtt)); |
| 3028 | |
| 3029 | REG_WRITE(ah, AR_BEACON_PERIOD, |
| 3030 | TU_TO_USEC(bs->bs_intval & ATH9K_BEACON_PERIOD)); |
| 3031 | REG_WRITE(ah, AR_DMA_BEACON_PERIOD, |
| 3032 | TU_TO_USEC(bs->bs_intval & ATH9K_BEACON_PERIOD)); |
| 3033 | |
| 3034 | REG_RMW_FIELD(ah, AR_RSSI_THR, |
| 3035 | AR_RSSI_THR_BM_THR, bs->bs_bmissthreshold); |
| 3036 | |
| 3037 | beaconintval = bs->bs_intval & ATH9K_BEACON_PERIOD; |
| 3038 | |
| 3039 | if (bs->bs_sleepduration > beaconintval) |
| 3040 | beaconintval = bs->bs_sleepduration; |
| 3041 | |
| 3042 | dtimperiod = bs->bs_dtimperiod; |
| 3043 | if (bs->bs_sleepduration > dtimperiod) |
| 3044 | dtimperiod = bs->bs_sleepduration; |
| 3045 | |
| 3046 | if (beaconintval == dtimperiod) |
| 3047 | nextTbtt = bs->bs_nextdtim; |
| 3048 | else |
| 3049 | nextTbtt = bs->bs_nexttbtt; |
| 3050 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3051 | ath_print(common, ATH_DBG_BEACON, "next DTIM %d\n", bs->bs_nextdtim); |
| 3052 | ath_print(common, ATH_DBG_BEACON, "next beacon %d\n", nextTbtt); |
| 3053 | ath_print(common, ATH_DBG_BEACON, "beacon period %d\n", beaconintval); |
| 3054 | ath_print(common, ATH_DBG_BEACON, "DTIM period %d\n", dtimperiod); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3055 | |
| 3056 | REG_WRITE(ah, AR_NEXT_DTIM, |
| 3057 | TU_TO_USEC(bs->bs_nextdtim - SLEEP_SLOP)); |
| 3058 | REG_WRITE(ah, AR_NEXT_TIM, TU_TO_USEC(nextTbtt - SLEEP_SLOP)); |
| 3059 | |
| 3060 | REG_WRITE(ah, AR_SLEEP1, |
| 3061 | SM((CAB_TIMEOUT_VAL << 3), AR_SLEEP1_CAB_TIMEOUT) |
| 3062 | | AR_SLEEP1_ASSUME_DTIM); |
| 3063 | |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 3064 | if (pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3065 | beacontimeout = (BEACON_TIMEOUT_VAL << 3); |
| 3066 | else |
| 3067 | beacontimeout = MIN_BEACON_TIMEOUT_VAL; |
| 3068 | |
| 3069 | REG_WRITE(ah, AR_SLEEP2, |
| 3070 | SM(beacontimeout, AR_SLEEP2_BEACON_TIMEOUT)); |
| 3071 | |
| 3072 | REG_WRITE(ah, AR_TIM_PERIOD, TU_TO_USEC(beaconintval)); |
| 3073 | REG_WRITE(ah, AR_DTIM_PERIOD, TU_TO_USEC(dtimperiod)); |
| 3074 | |
| 3075 | REG_SET_BIT(ah, AR_TIMER_MODE, |
| 3076 | AR_TBTT_TIMER_EN | AR_TIM_TIMER_EN | |
| 3077 | AR_DTIM_TIMER_EN); |
| 3078 | |
Sujith | 4af9cf4 | 2009-02-12 10:06:47 +0530 | [diff] [blame] | 3079 | /* TSF Out of Range Threshold */ |
| 3080 | REG_WRITE(ah, AR_TSFOOR_THRESHOLD, bs->bs_tsfoor_threshold); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3081 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3082 | EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_timers); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3083 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3084 | /*******************/ |
| 3085 | /* HW Capabilities */ |
| 3086 | /*******************/ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3087 | |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 3088 | int ath9k_hw_fill_cap_info(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3089 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3090 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3091 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3092 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 3093 | struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3094 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3095 | u16 capField = 0, eeval; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3096 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3097 | eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0); |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3098 | regulatory->current_rd = eeval; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3099 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3100 | eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1); |
Sujith | fec0de1 | 2009-02-12 10:06:43 +0530 | [diff] [blame] | 3101 | if (AR_SREV_9285_10_OR_LATER(ah)) |
| 3102 | eeval |= AR9285_RDEXT_DEFAULT; |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3103 | regulatory->current_rd_ext = eeval; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3104 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3105 | capField = ah->eep_ops->get_eeprom(ah, EEP_OP_CAP); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3106 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3107 | if (ah->opmode != NL80211_IFTYPE_AP && |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 3108 | ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) { |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3109 | if (regulatory->current_rd == 0x64 || |
| 3110 | regulatory->current_rd == 0x65) |
| 3111 | regulatory->current_rd += 5; |
| 3112 | else if (regulatory->current_rd == 0x41) |
| 3113 | regulatory->current_rd = 0x43; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3114 | ath_print(common, ATH_DBG_REGULATORY, |
| 3115 | "regdomain mapped to 0x%x\n", regulatory->current_rd); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3116 | } |
Sujith | dc2222a | 2008-08-14 13:26:55 +0530 | [diff] [blame] | 3117 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3118 | eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE); |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 3119 | if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) { |
| 3120 | ath_print(common, ATH_DBG_FATAL, |
| 3121 | "no band has been marked as supported in EEPROM.\n"); |
| 3122 | return -EINVAL; |
| 3123 | } |
| 3124 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3125 | bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3126 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3127 | if (eeval & AR5416_OPFLAGS_11A) { |
| 3128 | set_bit(ATH9K_MODE_11A, pCap->wireless_modes); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3129 | if (ah->config.ht_enable) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3130 | if (!(eeval & AR5416_OPFLAGS_N_5G_HT20)) |
| 3131 | set_bit(ATH9K_MODE_11NA_HT20, |
| 3132 | pCap->wireless_modes); |
| 3133 | if (!(eeval & AR5416_OPFLAGS_N_5G_HT40)) { |
| 3134 | set_bit(ATH9K_MODE_11NA_HT40PLUS, |
| 3135 | pCap->wireless_modes); |
| 3136 | set_bit(ATH9K_MODE_11NA_HT40MINUS, |
| 3137 | pCap->wireless_modes); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3138 | } |
| 3139 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3140 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3141 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3142 | if (eeval & AR5416_OPFLAGS_11G) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3143 | set_bit(ATH9K_MODE_11G, pCap->wireless_modes); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3144 | if (ah->config.ht_enable) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3145 | if (!(eeval & AR5416_OPFLAGS_N_2G_HT20)) |
| 3146 | set_bit(ATH9K_MODE_11NG_HT20, |
| 3147 | pCap->wireless_modes); |
| 3148 | if (!(eeval & AR5416_OPFLAGS_N_2G_HT40)) { |
| 3149 | set_bit(ATH9K_MODE_11NG_HT40PLUS, |
| 3150 | pCap->wireless_modes); |
| 3151 | set_bit(ATH9K_MODE_11NG_HT40MINUS, |
| 3152 | pCap->wireless_modes); |
| 3153 | } |
| 3154 | } |
Luis R. Rodriguez | 6f25542 | 2008-10-03 15:45:27 -0700 | [diff] [blame] | 3155 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3156 | |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3157 | pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK); |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 3158 | /* |
| 3159 | * For AR9271 we will temporarilly uses the rx chainmax as read from |
| 3160 | * the EEPROM. |
| 3161 | */ |
Sujith | 8147f5d | 2009-02-20 15:13:23 +0530 | [diff] [blame] | 3162 | if ((ah->hw_version.devid == AR5416_DEVID_PCI) && |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 3163 | !(eeval & AR5416_OPFLAGS_11A) && |
| 3164 | !(AR_SREV_9271(ah))) |
| 3165 | /* CB71: GPIO 0 is pulled down to indicate 3 rx chains */ |
Sujith | 8147f5d | 2009-02-20 15:13:23 +0530 | [diff] [blame] | 3166 | pCap->rx_chainmask = ath9k_hw_gpio_get(ah, 0) ? 0x5 : 0x7; |
| 3167 | else |
Luis R. Rodriguez | d7e7d22 | 2009-08-03 23:14:12 -0400 | [diff] [blame] | 3168 | /* Use rx_chainmask from EEPROM. */ |
Sujith | 8147f5d | 2009-02-20 15:13:23 +0530 | [diff] [blame] | 3169 | pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3170 | |
Sujith | d535a42 | 2009-02-09 13:27:06 +0530 | [diff] [blame] | 3171 | if (!(AR_SREV_9280(ah) && (ah->hw_version.macRev == 0))) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3172 | ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3173 | |
| 3174 | pCap->low_2ghz_chan = 2312; |
| 3175 | pCap->high_2ghz_chan = 2732; |
| 3176 | |
| 3177 | pCap->low_5ghz_chan = 4920; |
| 3178 | pCap->high_5ghz_chan = 6100; |
| 3179 | |
| 3180 | pCap->hw_caps &= ~ATH9K_HW_CAP_CIPHER_CKIP; |
| 3181 | pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_TKIP; |
| 3182 | pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_AESCCM; |
| 3183 | |
| 3184 | pCap->hw_caps &= ~ATH9K_HW_CAP_MIC_CKIP; |
| 3185 | pCap->hw_caps |= ATH9K_HW_CAP_MIC_TKIP; |
| 3186 | pCap->hw_caps |= ATH9K_HW_CAP_MIC_AESCCM; |
| 3187 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3188 | if (ah->config.ht_enable) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3189 | pCap->hw_caps |= ATH9K_HW_CAP_HT; |
| 3190 | else |
| 3191 | pCap->hw_caps &= ~ATH9K_HW_CAP_HT; |
| 3192 | |
| 3193 | pCap->hw_caps |= ATH9K_HW_CAP_GTT; |
| 3194 | pCap->hw_caps |= ATH9K_HW_CAP_VEOL; |
| 3195 | pCap->hw_caps |= ATH9K_HW_CAP_BSSIDMASK; |
| 3196 | pCap->hw_caps &= ~ATH9K_HW_CAP_MCAST_KEYSEARCH; |
| 3197 | |
| 3198 | if (capField & AR_EEPROM_EEPCAP_MAXQCU) |
| 3199 | pCap->total_queues = |
| 3200 | MS(capField, AR_EEPROM_EEPCAP_MAXQCU); |
| 3201 | else |
| 3202 | pCap->total_queues = ATH9K_NUM_TX_QUEUES; |
| 3203 | |
| 3204 | if (capField & AR_EEPROM_EEPCAP_KC_ENTRIES) |
| 3205 | pCap->keycache_size = |
| 3206 | 1 << MS(capField, AR_EEPROM_EEPCAP_KC_ENTRIES); |
| 3207 | else |
| 3208 | pCap->keycache_size = AR_KEYTABLE_SIZE; |
| 3209 | |
| 3210 | pCap->hw_caps |= ATH9K_HW_CAP_FASTCC; |
Luis R. Rodriguez | f4709fd | 2009-11-24 21:37:57 -0500 | [diff] [blame] | 3211 | |
| 3212 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) |
| 3213 | pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD >> 1; |
| 3214 | else |
| 3215 | pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3216 | |
Senthil Balasubramanian | cb33c41 | 2008-12-24 18:03:58 +0530 | [diff] [blame] | 3217 | if (AR_SREV_9285_10_OR_LATER(ah)) |
| 3218 | pCap->num_gpio_pins = AR9285_NUM_GPIO; |
| 3219 | else if (AR_SREV_9280_10_OR_LATER(ah)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3220 | pCap->num_gpio_pins = AR928X_NUM_GPIO; |
| 3221 | else |
| 3222 | pCap->num_gpio_pins = AR_NUM_GPIO; |
| 3223 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3224 | if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) { |
| 3225 | pCap->hw_caps |= ATH9K_HW_CAP_CST; |
| 3226 | pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX; |
| 3227 | } else { |
| 3228 | pCap->rts_aggr_limit = (8 * 1024); |
| 3229 | } |
| 3230 | |
| 3231 | pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM; |
| 3232 | |
Senthil Balasubramanian | e97275c | 2008-11-13 18:00:02 +0530 | [diff] [blame] | 3233 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3234 | ah->rfsilent = ah->eep_ops->get_eeprom(ah, EEP_RF_SILENT); |
| 3235 | if (ah->rfsilent & EEP_RFSILENT_ENABLED) { |
| 3236 | ah->rfkill_gpio = |
| 3237 | MS(ah->rfsilent, EEP_RFSILENT_GPIO_SEL); |
| 3238 | ah->rfkill_polarity = |
| 3239 | MS(ah->rfsilent, EEP_RFSILENT_POLARITY); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3240 | |
| 3241 | pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT; |
| 3242 | } |
| 3243 | #endif |
| 3244 | |
Vivek Natarajan | a3ca95fb | 2009-09-17 09:29:07 +0530 | [diff] [blame] | 3245 | pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3246 | |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 3247 | if (AR_SREV_9280(ah) || AR_SREV_9285(ah)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3248 | pCap->hw_caps &= ~ATH9K_HW_CAP_4KB_SPLITTRANS; |
| 3249 | else |
| 3250 | pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS; |
| 3251 | |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3252 | if (regulatory->current_rd_ext & (1 << REG_EXT_JAPAN_MIDBAND)) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3253 | pCap->reg_cap = |
| 3254 | AR_EEPROM_EEREGCAP_EN_KK_NEW_11A | |
| 3255 | AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN | |
| 3256 | AR_EEPROM_EEREGCAP_EN_KK_U2 | |
| 3257 | AR_EEPROM_EEREGCAP_EN_KK_MIDBAND; |
| 3258 | } else { |
| 3259 | pCap->reg_cap = |
| 3260 | AR_EEPROM_EEREGCAP_EN_KK_NEW_11A | |
| 3261 | AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN; |
| 3262 | } |
| 3263 | |
Senthil Balasubramanian | ebb90cf | 2009-09-18 15:07:33 +0530 | [diff] [blame] | 3264 | /* Advertise midband for AR5416 with FCC midband set in eeprom */ |
| 3265 | if (regulatory->current_rd_ext & (1 << REG_EXT_FCC_MIDBAND) && |
| 3266 | AR_SREV_5416(ah)) |
| 3267 | pCap->reg_cap |= AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3268 | |
| 3269 | pCap->num_antcfg_5ghz = |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3270 | ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_5GHZ); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3271 | pCap->num_antcfg_2ghz = |
Sujith | f74df6f | 2009-02-09 13:27:24 +0530 | [diff] [blame] | 3272 | ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_2GHZ); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3273 | |
Vasanthakumar Thiagarajan | fe12946 | 2009-09-09 15:25:50 +0530 | [diff] [blame] | 3274 | if (AR_SREV_9280_10_OR_LATER(ah) && |
Luis R. Rodriguez | a36cfbc | 2009-09-09 16:05:32 -0700 | [diff] [blame] | 3275 | ath9k_hw_btcoex_supported(ah)) { |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 3276 | btcoex_hw->btactive_gpio = ATH_BTACTIVE_GPIO; |
| 3277 | btcoex_hw->wlanactive_gpio = ATH_WLANACTIVE_GPIO; |
Vasanthakumar Thiagarajan | 22f25d0 | 2009-08-26 21:08:47 +0530 | [diff] [blame] | 3278 | |
Vasanthakumar Thiagarajan | 8c8f9ba | 2009-09-09 15:25:52 +0530 | [diff] [blame] | 3279 | if (AR_SREV_9285(ah)) { |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 3280 | btcoex_hw->scheme = ATH_BTCOEX_CFG_3WIRE; |
| 3281 | btcoex_hw->btpriority_gpio = ATH_BTPRIORITY_GPIO; |
Vasanthakumar Thiagarajan | 8c8f9ba | 2009-09-09 15:25:52 +0530 | [diff] [blame] | 3282 | } else { |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 3283 | btcoex_hw->scheme = ATH_BTCOEX_CFG_2WIRE; |
Vasanthakumar Thiagarajan | 8c8f9ba | 2009-09-09 15:25:52 +0530 | [diff] [blame] | 3284 | } |
Vasanthakumar Thiagarajan | 22f25d0 | 2009-08-26 21:08:47 +0530 | [diff] [blame] | 3285 | } else { |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 3286 | btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE; |
Vasanthakumar Thiagarajan | c97c92d | 2009-01-02 15:35:46 +0530 | [diff] [blame] | 3287 | } |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 3288 | |
| 3289 | return 0; |
Luis R. Rodriguez | 6f25542 | 2008-10-03 15:45:27 -0700 | [diff] [blame] | 3290 | } |
| 3291 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3292 | bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3293 | u32 capability, u32 *result) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3294 | { |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3295 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3296 | switch (type) { |
| 3297 | case ATH9K_CAP_CIPHER: |
| 3298 | switch (capability) { |
| 3299 | case ATH9K_CIPHER_AES_CCM: |
| 3300 | case ATH9K_CIPHER_AES_OCB: |
| 3301 | case ATH9K_CIPHER_TKIP: |
| 3302 | case ATH9K_CIPHER_WEP: |
| 3303 | case ATH9K_CIPHER_MIC: |
| 3304 | case ATH9K_CIPHER_CLR: |
| 3305 | return true; |
| 3306 | default: |
| 3307 | return false; |
| 3308 | } |
| 3309 | case ATH9K_CAP_TKIP_MIC: |
| 3310 | switch (capability) { |
| 3311 | case 0: |
| 3312 | return true; |
| 3313 | case 1: |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3314 | return (ah->sta_id1_defaults & |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3315 | AR_STA_ID1_CRPT_MIC_ENABLE) ? true : |
| 3316 | false; |
| 3317 | } |
| 3318 | case ATH9K_CAP_TKIP_SPLIT: |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3319 | return (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) ? |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3320 | false : true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3321 | case ATH9K_CAP_DIVERSITY: |
| 3322 | return (REG_READ(ah, AR_PHY_CCK_DETECT) & |
| 3323 | AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV) ? |
| 3324 | true : false; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3325 | case ATH9K_CAP_MCAST_KEYSRCH: |
| 3326 | switch (capability) { |
| 3327 | case 0: |
| 3328 | return true; |
| 3329 | case 1: |
| 3330 | if (REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_ADHOC) { |
| 3331 | return false; |
| 3332 | } else { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3333 | return (ah->sta_id1_defaults & |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3334 | AR_STA_ID1_MCAST_KSRCH) ? true : |
| 3335 | false; |
| 3336 | } |
| 3337 | } |
| 3338 | return false; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3339 | case ATH9K_CAP_TXPOW: |
| 3340 | switch (capability) { |
| 3341 | case 0: |
| 3342 | return 0; |
| 3343 | case 1: |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3344 | *result = regulatory->power_limit; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3345 | return 0; |
| 3346 | case 2: |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3347 | *result = regulatory->max_power_level; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3348 | return 0; |
| 3349 | case 3: |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3350 | *result = regulatory->tp_scale; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3351 | return 0; |
| 3352 | } |
| 3353 | return false; |
Senthil Balasubramanian | 8bd1d07 | 2009-02-12 13:57:03 +0530 | [diff] [blame] | 3354 | case ATH9K_CAP_DS: |
| 3355 | return (AR_SREV_9280_20_OR_LATER(ah) && |
| 3356 | (ah->eep_ops->get_eeprom(ah, EEP_RC_CHAIN_MASK) == 1)) |
| 3357 | ? false : true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3358 | default: |
| 3359 | return false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3360 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3361 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3362 | EXPORT_SYMBOL(ath9k_hw_getcapability); |
Luis R. Rodriguez | 6f25542 | 2008-10-03 15:45:27 -0700 | [diff] [blame] | 3363 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3364 | bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3365 | u32 capability, u32 setting, int *status) |
| 3366 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3367 | u32 v; |
Luis R. Rodriguez | 6f25542 | 2008-10-03 15:45:27 -0700 | [diff] [blame] | 3368 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3369 | switch (type) { |
| 3370 | case ATH9K_CAP_TKIP_MIC: |
| 3371 | if (setting) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3372 | ah->sta_id1_defaults |= |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3373 | AR_STA_ID1_CRPT_MIC_ENABLE; |
| 3374 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3375 | ah->sta_id1_defaults &= |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3376 | ~AR_STA_ID1_CRPT_MIC_ENABLE; |
| 3377 | return true; |
| 3378 | case ATH9K_CAP_DIVERSITY: |
| 3379 | v = REG_READ(ah, AR_PHY_CCK_DETECT); |
| 3380 | if (setting) |
| 3381 | v |= AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV; |
| 3382 | else |
| 3383 | v &= ~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV; |
| 3384 | REG_WRITE(ah, AR_PHY_CCK_DETECT, v); |
| 3385 | return true; |
| 3386 | case ATH9K_CAP_MCAST_KEYSRCH: |
| 3387 | if (setting) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3388 | ah->sta_id1_defaults |= AR_STA_ID1_MCAST_KSRCH; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3389 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3390 | ah->sta_id1_defaults &= ~AR_STA_ID1_MCAST_KSRCH; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3391 | return true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3392 | default: |
| 3393 | return false; |
| 3394 | } |
| 3395 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3396 | EXPORT_SYMBOL(ath9k_hw_setcapability); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3397 | |
| 3398 | /****************************/ |
| 3399 | /* GPIO / RFKILL / Antennae */ |
| 3400 | /****************************/ |
| 3401 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3402 | static void ath9k_hw_gpio_cfg_output_mux(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3403 | u32 gpio, u32 type) |
| 3404 | { |
| 3405 | int addr; |
| 3406 | u32 gpio_shift, tmp; |
| 3407 | |
| 3408 | if (gpio > 11) |
| 3409 | addr = AR_GPIO_OUTPUT_MUX3; |
| 3410 | else if (gpio > 5) |
| 3411 | addr = AR_GPIO_OUTPUT_MUX2; |
| 3412 | else |
| 3413 | addr = AR_GPIO_OUTPUT_MUX1; |
| 3414 | |
| 3415 | gpio_shift = (gpio % 6) * 5; |
| 3416 | |
| 3417 | if (AR_SREV_9280_20_OR_LATER(ah) |
| 3418 | || (addr != AR_GPIO_OUTPUT_MUX1)) { |
| 3419 | REG_RMW(ah, addr, (type << gpio_shift), |
| 3420 | (0x1f << gpio_shift)); |
| 3421 | } else { |
| 3422 | tmp = REG_READ(ah, addr); |
| 3423 | tmp = ((tmp & 0x1F0) << 1) | (tmp & ~0x1F0); |
| 3424 | tmp &= ~(0x1f << gpio_shift); |
| 3425 | tmp |= (type << gpio_shift); |
| 3426 | REG_WRITE(ah, addr, tmp); |
| 3427 | } |
| 3428 | } |
| 3429 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3430 | void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3431 | { |
| 3432 | u32 gpio_shift; |
| 3433 | |
Luis R. Rodriguez | 9680e8a | 2009-09-13 23:28:00 -0700 | [diff] [blame] | 3434 | BUG_ON(gpio >= ah->caps.num_gpio_pins); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3435 | |
| 3436 | gpio_shift = gpio << 1; |
| 3437 | |
| 3438 | REG_RMW(ah, |
| 3439 | AR_GPIO_OE_OUT, |
| 3440 | (AR_GPIO_OE_OUT_DRV_NO << gpio_shift), |
| 3441 | (AR_GPIO_OE_OUT_DRV << gpio_shift)); |
| 3442 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3443 | EXPORT_SYMBOL(ath9k_hw_cfg_gpio_input); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3444 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3445 | u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3446 | { |
Senthil Balasubramanian | cb33c41 | 2008-12-24 18:03:58 +0530 | [diff] [blame] | 3447 | #define MS_REG_READ(x, y) \ |
| 3448 | (MS(REG_READ(ah, AR_GPIO_IN_OUT), x##_GPIO_IN_VAL) & (AR_GPIO_BIT(y))) |
| 3449 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3450 | if (gpio >= ah->caps.num_gpio_pins) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3451 | return 0xffffffff; |
| 3452 | |
Vivek Natarajan | ac88b6e | 2009-07-23 10:59:57 +0530 | [diff] [blame] | 3453 | if (AR_SREV_9287_10_OR_LATER(ah)) |
| 3454 | return MS_REG_READ(AR9287, gpio) != 0; |
| 3455 | else if (AR_SREV_9285_10_OR_LATER(ah)) |
Senthil Balasubramanian | cb33c41 | 2008-12-24 18:03:58 +0530 | [diff] [blame] | 3456 | return MS_REG_READ(AR9285, gpio) != 0; |
| 3457 | else if (AR_SREV_9280_10_OR_LATER(ah)) |
| 3458 | return MS_REG_READ(AR928X, gpio) != 0; |
| 3459 | else |
| 3460 | return MS_REG_READ(AR, gpio) != 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3461 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3462 | EXPORT_SYMBOL(ath9k_hw_gpio_get); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3463 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3464 | void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3465 | u32 ah_signal_type) |
| 3466 | { |
| 3467 | u32 gpio_shift; |
| 3468 | |
| 3469 | ath9k_hw_gpio_cfg_output_mux(ah, gpio, ah_signal_type); |
| 3470 | |
| 3471 | gpio_shift = 2 * gpio; |
| 3472 | |
| 3473 | REG_RMW(ah, |
| 3474 | AR_GPIO_OE_OUT, |
| 3475 | (AR_GPIO_OE_OUT_DRV_ALL << gpio_shift), |
| 3476 | (AR_GPIO_OE_OUT_DRV << gpio_shift)); |
| 3477 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3478 | EXPORT_SYMBOL(ath9k_hw_cfg_output); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3479 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3480 | void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3481 | { |
| 3482 | REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio), |
| 3483 | AR_GPIO_BIT(gpio)); |
| 3484 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3485 | EXPORT_SYMBOL(ath9k_hw_set_gpio); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3486 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3487 | u32 ath9k_hw_getdefantenna(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3488 | { |
| 3489 | return REG_READ(ah, AR_DEF_ANTENNA) & 0x7; |
| 3490 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3491 | EXPORT_SYMBOL(ath9k_hw_getdefantenna); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3492 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3493 | void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3494 | { |
| 3495 | REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7)); |
| 3496 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3497 | EXPORT_SYMBOL(ath9k_hw_setantenna); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3498 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3499 | /*********************/ |
| 3500 | /* General Operation */ |
| 3501 | /*********************/ |
| 3502 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3503 | u32 ath9k_hw_getrxfilter(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3504 | { |
| 3505 | u32 bits = REG_READ(ah, AR_RX_FILTER); |
| 3506 | u32 phybits = REG_READ(ah, AR_PHY_ERR); |
| 3507 | |
| 3508 | if (phybits & AR_PHY_ERR_RADAR) |
| 3509 | bits |= ATH9K_RX_FILTER_PHYRADAR; |
| 3510 | if (phybits & (AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING)) |
| 3511 | bits |= ATH9K_RX_FILTER_PHYERR; |
| 3512 | |
| 3513 | return bits; |
| 3514 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3515 | EXPORT_SYMBOL(ath9k_hw_getrxfilter); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3516 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3517 | void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3518 | { |
| 3519 | u32 phybits; |
| 3520 | |
Sujith | 7ea310b | 2009-09-03 12:08:43 +0530 | [diff] [blame] | 3521 | REG_WRITE(ah, AR_RX_FILTER, bits); |
| 3522 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3523 | phybits = 0; |
| 3524 | if (bits & ATH9K_RX_FILTER_PHYRADAR) |
| 3525 | phybits |= AR_PHY_ERR_RADAR; |
| 3526 | if (bits & ATH9K_RX_FILTER_PHYERR) |
| 3527 | phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING; |
| 3528 | REG_WRITE(ah, AR_PHY_ERR, phybits); |
| 3529 | |
| 3530 | if (phybits) |
| 3531 | REG_WRITE(ah, AR_RXCFG, |
| 3532 | REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA); |
| 3533 | else |
| 3534 | REG_WRITE(ah, AR_RXCFG, |
| 3535 | REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_ZLFDMA); |
| 3536 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3537 | EXPORT_SYMBOL(ath9k_hw_setrxfilter); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3538 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3539 | bool ath9k_hw_phy_disable(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3540 | { |
Senthil Balasubramanian | 63a75b9 | 2009-09-18 15:07:03 +0530 | [diff] [blame] | 3541 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM)) |
| 3542 | return false; |
| 3543 | |
| 3544 | ath9k_hw_init_pll(ah, NULL); |
| 3545 | return true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3546 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3547 | EXPORT_SYMBOL(ath9k_hw_phy_disable); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3548 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3549 | bool ath9k_hw_disable(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3550 | { |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 3551 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3552 | return false; |
| 3553 | |
Senthil Balasubramanian | 63a75b9 | 2009-09-18 15:07:03 +0530 | [diff] [blame] | 3554 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD)) |
| 3555 | return false; |
| 3556 | |
| 3557 | ath9k_hw_init_pll(ah, NULL); |
| 3558 | return true; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3559 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3560 | EXPORT_SYMBOL(ath9k_hw_disable); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3561 | |
Vasanthakumar Thiagarajan | 8fbff4b | 2009-05-08 17:54:51 -0700 | [diff] [blame] | 3562 | void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3563 | { |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3564 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3565 | struct ath9k_channel *chan = ah->curchan; |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 3566 | struct ieee80211_channel *channel = chan->chan; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3567 | |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3568 | regulatory->power_limit = min(limit, (u32) MAX_RATE_POWER); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3569 | |
Vasanthakumar Thiagarajan | 8fbff4b | 2009-05-08 17:54:51 -0700 | [diff] [blame] | 3570 | ah->eep_ops->set_txpower(ah, chan, |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3571 | ath9k_regd_get_ctl(regulatory, chan), |
Vasanthakumar Thiagarajan | 8fbff4b | 2009-05-08 17:54:51 -0700 | [diff] [blame] | 3572 | channel->max_antenna_gain * 2, |
| 3573 | channel->max_power * 2, |
| 3574 | min((u32) MAX_RATE_POWER, |
Luis R. Rodriguez | 608b88c | 2009-08-17 18:07:23 -0700 | [diff] [blame] | 3575 | (u32) regulatory->power_limit)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3576 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3577 | EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3578 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3579 | void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3580 | { |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 3581 | memcpy(ath9k_hw_common(ah)->macaddr, mac, ETH_ALEN); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3582 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3583 | EXPORT_SYMBOL(ath9k_hw_setmac); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3584 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3585 | void ath9k_hw_setopmode(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3586 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3587 | ath9k_hw_set_operating_mode(ah, ah->opmode); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3588 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3589 | EXPORT_SYMBOL(ath9k_hw_setopmode); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3590 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3591 | void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3592 | { |
| 3593 | REG_WRITE(ah, AR_MCAST_FIL0, filter0); |
| 3594 | REG_WRITE(ah, AR_MCAST_FIL1, filter1); |
| 3595 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3596 | EXPORT_SYMBOL(ath9k_hw_setmcastfilter); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3597 | |
Luis R. Rodriguez | f2b2143 | 2009-09-10 08:50:20 -0700 | [diff] [blame] | 3598 | void ath9k_hw_write_associd(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3599 | { |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 3600 | struct ath_common *common = ath9k_hw_common(ah); |
| 3601 | |
| 3602 | REG_WRITE(ah, AR_BSS_ID0, get_unaligned_le32(common->curbssid)); |
| 3603 | REG_WRITE(ah, AR_BSS_ID1, get_unaligned_le16(common->curbssid + 4) | |
| 3604 | ((common->curaid & 0x3fff) << AR_BSS_ID1_AID_S)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3605 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3606 | EXPORT_SYMBOL(ath9k_hw_write_associd); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3607 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3608 | u64 ath9k_hw_gettsf64(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3609 | { |
| 3610 | u64 tsf; |
| 3611 | |
| 3612 | tsf = REG_READ(ah, AR_TSF_U32); |
| 3613 | tsf = (tsf << 32) | REG_READ(ah, AR_TSF_L32); |
| 3614 | |
| 3615 | return tsf; |
| 3616 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3617 | EXPORT_SYMBOL(ath9k_hw_gettsf64); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3618 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3619 | void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64) |
Alina Friedrichsen | 27abe06 | 2009-01-23 05:44:21 +0100 | [diff] [blame] | 3620 | { |
Alina Friedrichsen | 27abe06 | 2009-01-23 05:44:21 +0100 | [diff] [blame] | 3621 | REG_WRITE(ah, AR_TSF_L32, tsf64 & 0xffffffff); |
Alina Friedrichsen | b9a1619 | 2009-03-02 23:28:38 +0100 | [diff] [blame] | 3622 | REG_WRITE(ah, AR_TSF_U32, (tsf64 >> 32) & 0xffffffff); |
Alina Friedrichsen | 27abe06 | 2009-01-23 05:44:21 +0100 | [diff] [blame] | 3623 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3624 | EXPORT_SYMBOL(ath9k_hw_settsf64); |
Alina Friedrichsen | 27abe06 | 2009-01-23 05:44:21 +0100 | [diff] [blame] | 3625 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3626 | void ath9k_hw_reset_tsf(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3627 | { |
Gabor Juhos | f9b604f | 2009-06-21 00:02:15 +0200 | [diff] [blame] | 3628 | if (!ath9k_hw_wait(ah, AR_SLP32_MODE, AR_SLP32_TSF_WRITE_STATUS, 0, |
| 3629 | AH_TSF_WRITE_TIMEOUT)) |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3630 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, |
| 3631 | "AR_SLP32_TSF_WRITE_STATUS limit exceeded\n"); |
Gabor Juhos | f9b604f | 2009-06-21 00:02:15 +0200 | [diff] [blame] | 3632 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3633 | REG_WRITE(ah, AR_RESET_TSF, AR_RESET_TSF_ONCE); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3634 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3635 | EXPORT_SYMBOL(ath9k_hw_reset_tsf); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3636 | |
Sujith | 54e4cec | 2009-08-07 09:45:09 +0530 | [diff] [blame] | 3637 | void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3638 | { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3639 | if (setting) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3640 | ah->misc_mode |= AR_PCU_TX_ADD_TSF; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3641 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3642 | ah->misc_mode &= ~AR_PCU_TX_ADD_TSF; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3643 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3644 | EXPORT_SYMBOL(ath9k_hw_set_tsfadjust); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3645 | |
Luis R. Rodriguez | 30cbd42 | 2009-11-03 16:10:46 -0800 | [diff] [blame] | 3646 | /* |
| 3647 | * Extend 15-bit time stamp from rx descriptor to |
| 3648 | * a full 64-bit TSF using the current h/w TSF. |
| 3649 | */ |
| 3650 | u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp) |
| 3651 | { |
| 3652 | u64 tsf; |
| 3653 | |
| 3654 | tsf = ath9k_hw_gettsf64(ah); |
| 3655 | if ((tsf & 0x7fff) < rstamp) |
| 3656 | tsf -= 0x8000; |
| 3657 | return (tsf & ~0x7fff) | rstamp; |
| 3658 | } |
| 3659 | EXPORT_SYMBOL(ath9k_hw_extend_tsf); |
| 3660 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 3661 | bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3662 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3663 | if (us < ATH9K_SLOT_TIME_9 || us > ath9k_hw_mac_to_usec(ah, 0xffff)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3664 | ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, |
| 3665 | "bad slot time %u\n", us); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3666 | ah->slottime = (u32) -1; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3667 | return false; |
| 3668 | } else { |
| 3669 | REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath9k_hw_mac_to_clks(ah, us)); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 3670 | ah->slottime = us; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3671 | return true; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3672 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3673 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3674 | EXPORT_SYMBOL(ath9k_hw_setslottime); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3675 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 3676 | void ath9k_hw_set11nmac2040(struct ath_hw *ah) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3677 | { |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 3678 | struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3679 | u32 macmode; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3680 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 3681 | if (conf_is_ht40(conf) && !ah->config.cwm_ignore_extcca) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3682 | macmode = AR_2040_JOINED_RX_CLEAR; |
| 3683 | else |
| 3684 | macmode = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3685 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 3686 | REG_WRITE(ah, AR_2040_MODE, macmode); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3687 | } |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3688 | |
| 3689 | /* HW Generic timers configuration */ |
| 3690 | |
| 3691 | static const struct ath_gen_timer_configuration gen_tmr_configuration[] = |
| 3692 | { |
| 3693 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3694 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3695 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3696 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3697 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3698 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3699 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3700 | {AR_NEXT_NDP_TIMER, AR_NDP_PERIOD, AR_TIMER_MODE, 0x0080}, |
| 3701 | {AR_NEXT_NDP2_TIMER, AR_NDP2_PERIOD, AR_NDP2_TIMER_MODE, 0x0001}, |
| 3702 | {AR_NEXT_NDP2_TIMER + 1*4, AR_NDP2_PERIOD + 1*4, |
| 3703 | AR_NDP2_TIMER_MODE, 0x0002}, |
| 3704 | {AR_NEXT_NDP2_TIMER + 2*4, AR_NDP2_PERIOD + 2*4, |
| 3705 | AR_NDP2_TIMER_MODE, 0x0004}, |
| 3706 | {AR_NEXT_NDP2_TIMER + 3*4, AR_NDP2_PERIOD + 3*4, |
| 3707 | AR_NDP2_TIMER_MODE, 0x0008}, |
| 3708 | {AR_NEXT_NDP2_TIMER + 4*4, AR_NDP2_PERIOD + 4*4, |
| 3709 | AR_NDP2_TIMER_MODE, 0x0010}, |
| 3710 | {AR_NEXT_NDP2_TIMER + 5*4, AR_NDP2_PERIOD + 5*4, |
| 3711 | AR_NDP2_TIMER_MODE, 0x0020}, |
| 3712 | {AR_NEXT_NDP2_TIMER + 6*4, AR_NDP2_PERIOD + 6*4, |
| 3713 | AR_NDP2_TIMER_MODE, 0x0040}, |
| 3714 | {AR_NEXT_NDP2_TIMER + 7*4, AR_NDP2_PERIOD + 7*4, |
| 3715 | AR_NDP2_TIMER_MODE, 0x0080} |
| 3716 | }; |
| 3717 | |
| 3718 | /* HW generic timer primitives */ |
| 3719 | |
| 3720 | /* compute and clear index of rightmost 1 */ |
| 3721 | static u32 rightmost_index(struct ath_gen_timer_table *timer_table, u32 *mask) |
| 3722 | { |
| 3723 | u32 b; |
| 3724 | |
| 3725 | b = *mask; |
| 3726 | b &= (0-b); |
| 3727 | *mask &= ~b; |
| 3728 | b *= debruijn32; |
| 3729 | b >>= 27; |
| 3730 | |
| 3731 | return timer_table->gen_timer_index[b]; |
| 3732 | } |
| 3733 | |
Vasanthakumar Thiagarajan | 1773912 | 2009-08-26 21:08:50 +0530 | [diff] [blame] | 3734 | u32 ath9k_hw_gettsf32(struct ath_hw *ah) |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3735 | { |
| 3736 | return REG_READ(ah, AR_TSF_L32); |
| 3737 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3738 | EXPORT_SYMBOL(ath9k_hw_gettsf32); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3739 | |
| 3740 | struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, |
| 3741 | void (*trigger)(void *), |
| 3742 | void (*overflow)(void *), |
| 3743 | void *arg, |
| 3744 | u8 timer_index) |
| 3745 | { |
| 3746 | struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; |
| 3747 | struct ath_gen_timer *timer; |
| 3748 | |
| 3749 | timer = kzalloc(sizeof(struct ath_gen_timer), GFP_KERNEL); |
| 3750 | |
| 3751 | if (timer == NULL) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3752 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 3753 | "Failed to allocate memory" |
| 3754 | "for hw timer[%d]\n", timer_index); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3755 | return NULL; |
| 3756 | } |
| 3757 | |
| 3758 | /* allocate a hardware generic timer slot */ |
| 3759 | timer_table->timers[timer_index] = timer; |
| 3760 | timer->index = timer_index; |
| 3761 | timer->trigger = trigger; |
| 3762 | timer->overflow = overflow; |
| 3763 | timer->arg = arg; |
| 3764 | |
| 3765 | return timer; |
| 3766 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3767 | EXPORT_SYMBOL(ath_gen_timer_alloc); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3768 | |
Luis R. Rodriguez | cd9bf68 | 2009-09-13 02:08:34 -0700 | [diff] [blame] | 3769 | void ath9k_hw_gen_timer_start(struct ath_hw *ah, |
| 3770 | struct ath_gen_timer *timer, |
| 3771 | u32 timer_next, |
| 3772 | u32 timer_period) |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3773 | { |
| 3774 | struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; |
| 3775 | u32 tsf; |
| 3776 | |
| 3777 | BUG_ON(!timer_period); |
| 3778 | |
| 3779 | set_bit(timer->index, &timer_table->timer_mask.timer_bits); |
| 3780 | |
| 3781 | tsf = ath9k_hw_gettsf32(ah); |
| 3782 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3783 | ath_print(ath9k_hw_common(ah), ATH_DBG_HWTIMER, |
| 3784 | "curent tsf %x period %x" |
| 3785 | "timer_next %x\n", tsf, timer_period, timer_next); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3786 | |
| 3787 | /* |
| 3788 | * Pull timer_next forward if the current TSF already passed it |
| 3789 | * because of software latency |
| 3790 | */ |
| 3791 | if (timer_next < tsf) |
| 3792 | timer_next = tsf + timer_period; |
| 3793 | |
| 3794 | /* |
| 3795 | * Program generic timer registers |
| 3796 | */ |
| 3797 | REG_WRITE(ah, gen_tmr_configuration[timer->index].next_addr, |
| 3798 | timer_next); |
| 3799 | REG_WRITE(ah, gen_tmr_configuration[timer->index].period_addr, |
| 3800 | timer_period); |
| 3801 | REG_SET_BIT(ah, gen_tmr_configuration[timer->index].mode_addr, |
| 3802 | gen_tmr_configuration[timer->index].mode_mask); |
| 3803 | |
| 3804 | /* Enable both trigger and thresh interrupt masks */ |
| 3805 | REG_SET_BIT(ah, AR_IMR_S5, |
| 3806 | (SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_THRESH) | |
| 3807 | SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_TRIG))); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3808 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3809 | EXPORT_SYMBOL(ath9k_hw_gen_timer_start); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3810 | |
Luis R. Rodriguez | cd9bf68 | 2009-09-13 02:08:34 -0700 | [diff] [blame] | 3811 | void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer) |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3812 | { |
| 3813 | struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; |
| 3814 | |
| 3815 | if ((timer->index < AR_FIRST_NDP_TIMER) || |
| 3816 | (timer->index >= ATH_MAX_GEN_TIMER)) { |
| 3817 | return; |
| 3818 | } |
| 3819 | |
| 3820 | /* Clear generic timer enable bits. */ |
| 3821 | REG_CLR_BIT(ah, gen_tmr_configuration[timer->index].mode_addr, |
| 3822 | gen_tmr_configuration[timer->index].mode_mask); |
| 3823 | |
| 3824 | /* Disable both trigger and thresh interrupt masks */ |
| 3825 | REG_CLR_BIT(ah, AR_IMR_S5, |
| 3826 | (SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_THRESH) | |
| 3827 | SM(AR_GENTMR_BIT(timer->index), AR_IMR_S5_GENTIMER_TRIG))); |
| 3828 | |
| 3829 | clear_bit(timer->index, &timer_table->timer_mask.timer_bits); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3830 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3831 | EXPORT_SYMBOL(ath9k_hw_gen_timer_stop); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3832 | |
| 3833 | void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer) |
| 3834 | { |
| 3835 | struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; |
| 3836 | |
| 3837 | /* free the hardware generic timer slot */ |
| 3838 | timer_table->timers[timer->index] = NULL; |
| 3839 | kfree(timer); |
| 3840 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3841 | EXPORT_SYMBOL(ath_gen_timer_free); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3842 | |
| 3843 | /* |
| 3844 | * Generic Timer Interrupts handling |
| 3845 | */ |
| 3846 | void ath_gen_timer_isr(struct ath_hw *ah) |
| 3847 | { |
| 3848 | struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; |
| 3849 | struct ath_gen_timer *timer; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3850 | struct ath_common *common = ath9k_hw_common(ah); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3851 | u32 trigger_mask, thresh_mask, index; |
| 3852 | |
| 3853 | /* get hardware generic timer interrupt status */ |
| 3854 | trigger_mask = ah->intr_gen_timer_trigger; |
| 3855 | thresh_mask = ah->intr_gen_timer_thresh; |
| 3856 | trigger_mask &= timer_table->timer_mask.val; |
| 3857 | thresh_mask &= timer_table->timer_mask.val; |
| 3858 | |
| 3859 | trigger_mask &= ~thresh_mask; |
| 3860 | |
| 3861 | while (thresh_mask) { |
| 3862 | index = rightmost_index(timer_table, &thresh_mask); |
| 3863 | timer = timer_table->timers[index]; |
| 3864 | BUG_ON(!timer); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3865 | ath_print(common, ATH_DBG_HWTIMER, |
| 3866 | "TSF overflow for Gen timer %d\n", index); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3867 | timer->overflow(timer->arg); |
| 3868 | } |
| 3869 | |
| 3870 | while (trigger_mask) { |
| 3871 | index = rightmost_index(timer_table, &trigger_mask); |
| 3872 | timer = timer_table->timers[index]; |
| 3873 | BUG_ON(!timer); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 3874 | ath_print(common, ATH_DBG_HWTIMER, |
| 3875 | "Gen timer[%d] trigger\n", index); |
Vasanthakumar Thiagarajan | ff155a4 | 2009-08-26 21:08:49 +0530 | [diff] [blame] | 3876 | timer->trigger(timer->arg); |
| 3877 | } |
| 3878 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 3879 | EXPORT_SYMBOL(ath_gen_timer_isr); |
Luis R. Rodriguez | 2da4f01 | 2009-10-27 12:59:33 -0400 | [diff] [blame] | 3880 | |
| 3881 | static struct { |
| 3882 | u32 version; |
| 3883 | const char * name; |
| 3884 | } ath_mac_bb_names[] = { |
| 3885 | /* Devices with external radios */ |
| 3886 | { AR_SREV_VERSION_5416_PCI, "5416" }, |
| 3887 | { AR_SREV_VERSION_5416_PCIE, "5418" }, |
| 3888 | { AR_SREV_VERSION_9100, "9100" }, |
| 3889 | { AR_SREV_VERSION_9160, "9160" }, |
| 3890 | /* Single-chip solutions */ |
| 3891 | { AR_SREV_VERSION_9280, "9280" }, |
| 3892 | { AR_SREV_VERSION_9285, "9285" }, |
Luis R. Rodriguez | 1115847 | 2009-10-27 12:59:35 -0400 | [diff] [blame] | 3893 | { AR_SREV_VERSION_9287, "9287" }, |
| 3894 | { AR_SREV_VERSION_9271, "9271" }, |
Luis R. Rodriguez | 2da4f01 | 2009-10-27 12:59:33 -0400 | [diff] [blame] | 3895 | }; |
| 3896 | |
| 3897 | /* For devices with external radios */ |
| 3898 | static struct { |
| 3899 | u16 version; |
| 3900 | const char * name; |
| 3901 | } ath_rf_names[] = { |
| 3902 | { 0, "5133" }, |
| 3903 | { AR_RAD5133_SREV_MAJOR, "5133" }, |
| 3904 | { AR_RAD5122_SREV_MAJOR, "5122" }, |
| 3905 | { AR_RAD2133_SREV_MAJOR, "2133" }, |
| 3906 | { AR_RAD2122_SREV_MAJOR, "2122" } |
| 3907 | }; |
| 3908 | |
| 3909 | /* |
| 3910 | * Return the MAC/BB name. "????" is returned if the MAC/BB is unknown. |
| 3911 | */ |
Luis R. Rodriguez | f934c4d | 2009-10-27 12:59:34 -0400 | [diff] [blame] | 3912 | static const char *ath9k_hw_mac_bb_name(u32 mac_bb_version) |
Luis R. Rodriguez | 2da4f01 | 2009-10-27 12:59:33 -0400 | [diff] [blame] | 3913 | { |
| 3914 | int i; |
| 3915 | |
| 3916 | for (i=0; i<ARRAY_SIZE(ath_mac_bb_names); i++) { |
| 3917 | if (ath_mac_bb_names[i].version == mac_bb_version) { |
| 3918 | return ath_mac_bb_names[i].name; |
| 3919 | } |
| 3920 | } |
| 3921 | |
| 3922 | return "????"; |
| 3923 | } |
Luis R. Rodriguez | 2da4f01 | 2009-10-27 12:59:33 -0400 | [diff] [blame] | 3924 | |
| 3925 | /* |
| 3926 | * Return the RF name. "????" is returned if the RF is unknown. |
| 3927 | * Used for devices with external radios. |
| 3928 | */ |
Luis R. Rodriguez | f934c4d | 2009-10-27 12:59:34 -0400 | [diff] [blame] | 3929 | static const char *ath9k_hw_rf_name(u16 rf_version) |
Luis R. Rodriguez | 2da4f01 | 2009-10-27 12:59:33 -0400 | [diff] [blame] | 3930 | { |
| 3931 | int i; |
| 3932 | |
| 3933 | for (i=0; i<ARRAY_SIZE(ath_rf_names); i++) { |
| 3934 | if (ath_rf_names[i].version == rf_version) { |
| 3935 | return ath_rf_names[i].name; |
| 3936 | } |
| 3937 | } |
| 3938 | |
| 3939 | return "????"; |
| 3940 | } |
Luis R. Rodriguez | f934c4d | 2009-10-27 12:59:34 -0400 | [diff] [blame] | 3941 | |
| 3942 | void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len) |
| 3943 | { |
| 3944 | int used; |
| 3945 | |
| 3946 | /* chipsets >= AR9280 are single-chip */ |
| 3947 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
| 3948 | used = snprintf(hw_name, len, |
| 3949 | "Atheros AR%s Rev:%x", |
| 3950 | ath9k_hw_mac_bb_name(ah->hw_version.macVersion), |
| 3951 | ah->hw_version.macRev); |
| 3952 | } |
| 3953 | else { |
| 3954 | used = snprintf(hw_name, len, |
| 3955 | "Atheros AR%s MAC/BB Rev:%x AR%s RF Rev:%x", |
| 3956 | ath9k_hw_mac_bb_name(ah->hw_version.macVersion), |
| 3957 | ah->hw_version.macRev, |
| 3958 | ath9k_hw_rf_name((ah->hw_version.analog5GhzRev & |
| 3959 | AR_RADIO_SREV_MAJOR)), |
| 3960 | ah->hw_version.phyRev); |
| 3961 | } |
| 3962 | |
| 3963 | hw_name[used] = '\0'; |
| 3964 | } |
| 3965 | EXPORT_SYMBOL(ath9k_hw_name); |