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