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