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