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