Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 1 | /* |
Sujith Manoharan | 5b68138 | 2011-05-17 13:36:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [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 | |
Paul Gortmaker | 6eb07ca | 2011-09-15 19:46:05 -0400 | [diff] [blame^] | 17 | #include <linux/moduleparam.h> |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 18 | #include "hw.h" |
| 19 | #include "ar5008_initvals.h" |
| 20 | #include "ar9001_initvals.h" |
| 21 | #include "ar9002_initvals.h" |
Sujith | e9141f7 | 2010-06-01 15:14:10 +0530 | [diff] [blame] | 22 | #include "ar9002_phy.h" |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 23 | |
Luis R. Rodriguez | e36b27a | 2010-06-12 00:33:45 -0400 | [diff] [blame] | 24 | int modparam_force_new_ani; |
| 25 | module_param_named(force_new_ani, modparam_force_new_ani, int, 0444); |
John W. Linville | 33af881 | 2011-01-05 14:05:00 -0500 | [diff] [blame] | 26 | MODULE_PARM_DESC(force_new_ani, "Force new ANI for AR5008, AR9001, AR9002"); |
Luis R. Rodriguez | e36b27a | 2010-06-12 00:33:45 -0400 | [diff] [blame] | 27 | |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 28 | /* General hardware code for the A5008/AR9001/AR9002 hadware families */ |
| 29 | |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 30 | static void ar9002_hw_init_mode_regs(struct ath_hw *ah) |
| 31 | { |
| 32 | if (AR_SREV_9271(ah)) { |
| 33 | INIT_INI_ARRAY(&ah->iniModes, ar9271Modes_9271, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 34 | ARRAY_SIZE(ar9271Modes_9271), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 35 | INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, |
| 36 | ARRAY_SIZE(ar9271Common_9271), 2); |
| 37 | INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271, |
| 38 | ar9271Common_normal_cck_fir_coeff_9271, |
| 39 | ARRAY_SIZE(ar9271Common_normal_cck_fir_coeff_9271), 2); |
| 40 | INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271, |
| 41 | ar9271Common_japan_2484_cck_fir_coeff_9271, |
| 42 | ARRAY_SIZE(ar9271Common_japan_2484_cck_fir_coeff_9271), 2); |
| 43 | INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, |
| 44 | ar9271Modes_9271_1_0_only, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 45 | ARRAY_SIZE(ar9271Modes_9271_1_0_only), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 46 | INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 47 | ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 48 | INIT_INI_ARRAY(&ah->iniModes_high_power_tx_gain_9271, |
| 49 | ar9271Modes_high_power_tx_gain_9271, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 50 | ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 51 | INIT_INI_ARRAY(&ah->iniModes_normal_power_tx_gain_9271, |
| 52 | ar9271Modes_normal_power_tx_gain_9271, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 53 | ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 54 | return; |
| 55 | } |
| 56 | |
| 57 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
| 58 | INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 59 | ARRAY_SIZE(ar9287Modes_9287_1_1), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 60 | INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1, |
| 61 | ARRAY_SIZE(ar9287Common_9287_1_1), 2); |
| 62 | if (ah->config.pcie_clock_req) |
| 63 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 64 | ar9287PciePhy_clkreq_off_L1_9287_1_1, |
| 65 | ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_1), 2); |
| 66 | else |
| 67 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 68 | ar9287PciePhy_clkreq_always_on_L1_9287_1_1, |
| 69 | ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_1), |
| 70 | 2); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 71 | } else if (AR_SREV_9285_12_OR_LATER(ah)) { |
| 72 | |
| 73 | |
| 74 | INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 75 | ARRAY_SIZE(ar9285Modes_9285_1_2), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 76 | INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2, |
| 77 | ARRAY_SIZE(ar9285Common_9285_1_2), 2); |
| 78 | |
| 79 | if (ah->config.pcie_clock_req) { |
| 80 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 81 | ar9285PciePhy_clkreq_off_L1_9285_1_2, |
| 82 | ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285_1_2), 2); |
| 83 | } else { |
| 84 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 85 | ar9285PciePhy_clkreq_always_on_L1_9285_1_2, |
| 86 | ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285_1_2), |
| 87 | 2); |
| 88 | } |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 89 | } else if (AR_SREV_9280_20_OR_LATER(ah)) { |
| 90 | INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 91 | ARRAY_SIZE(ar9280Modes_9280_2), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 92 | INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2, |
| 93 | ARRAY_SIZE(ar9280Common_9280_2), 2); |
| 94 | |
| 95 | if (ah->config.pcie_clock_req) { |
| 96 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 97 | ar9280PciePhy_clkreq_off_L1_9280, |
| 98 | ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280), 2); |
| 99 | } else { |
| 100 | INIT_INI_ARRAY(&ah->iniPcieSerdes, |
| 101 | ar9280PciePhy_clkreq_always_on_L1_9280, |
| 102 | ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2); |
| 103 | } |
| 104 | INIT_INI_ARRAY(&ah->iniModesAdditional, |
| 105 | ar9280Modes_fast_clock_9280_2, |
| 106 | ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 107 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { |
| 108 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 109 | ARRAY_SIZE(ar5416Modes_9160), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 110 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160, |
| 111 | ARRAY_SIZE(ar5416Common_9160), 2); |
| 112 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9160, |
| 113 | ARRAY_SIZE(ar5416Bank0_9160), 2); |
| 114 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9160, |
| 115 | ARRAY_SIZE(ar5416BB_RfGain_9160), 3); |
| 116 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9160, |
| 117 | ARRAY_SIZE(ar5416Bank1_9160), 2); |
| 118 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9160, |
| 119 | ARRAY_SIZE(ar5416Bank2_9160), 2); |
| 120 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9160, |
| 121 | ARRAY_SIZE(ar5416Bank3_9160), 3); |
| 122 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9160, |
| 123 | ARRAY_SIZE(ar5416Bank6_9160), 3); |
| 124 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9160, |
| 125 | ARRAY_SIZE(ar5416Bank6TPC_9160), 3); |
| 126 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9160, |
| 127 | ARRAY_SIZE(ar5416Bank7_9160), 2); |
| 128 | if (AR_SREV_9160_11(ah)) { |
| 129 | INIT_INI_ARRAY(&ah->iniAddac, |
Felix Fietkau | f504f5f | 2010-07-02 00:09:47 +0200 | [diff] [blame] | 130 | ar5416Addac_9160_1_1, |
| 131 | ARRAY_SIZE(ar5416Addac_9160_1_1), 2); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 132 | } else { |
| 133 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160, |
| 134 | ARRAY_SIZE(ar5416Addac_9160), 2); |
| 135 | } |
| 136 | } else if (AR_SREV_9100_OR_LATER(ah)) { |
| 137 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 138 | ARRAY_SIZE(ar5416Modes_9100), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 139 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100, |
| 140 | ARRAY_SIZE(ar5416Common_9100), 2); |
| 141 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9100, |
| 142 | ARRAY_SIZE(ar5416Bank0_9100), 2); |
| 143 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9100, |
| 144 | ARRAY_SIZE(ar5416BB_RfGain_9100), 3); |
| 145 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9100, |
| 146 | ARRAY_SIZE(ar5416Bank1_9100), 2); |
| 147 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9100, |
| 148 | ARRAY_SIZE(ar5416Bank2_9100), 2); |
| 149 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9100, |
| 150 | ARRAY_SIZE(ar5416Bank3_9100), 3); |
| 151 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100, |
| 152 | ARRAY_SIZE(ar5416Bank6_9100), 3); |
| 153 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100, |
| 154 | ARRAY_SIZE(ar5416Bank6TPC_9100), 3); |
| 155 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9100, |
| 156 | ARRAY_SIZE(ar5416Bank7_9100), 2); |
| 157 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100, |
| 158 | ARRAY_SIZE(ar5416Addac_9100), 2); |
| 159 | } else { |
| 160 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 161 | ARRAY_SIZE(ar5416Modes), 5); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 162 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common, |
| 163 | ARRAY_SIZE(ar5416Common), 2); |
| 164 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0, |
| 165 | ARRAY_SIZE(ar5416Bank0), 2); |
| 166 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain, |
| 167 | ARRAY_SIZE(ar5416BB_RfGain), 3); |
| 168 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1, |
| 169 | ARRAY_SIZE(ar5416Bank1), 2); |
| 170 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2, |
| 171 | ARRAY_SIZE(ar5416Bank2), 2); |
| 172 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3, |
| 173 | ARRAY_SIZE(ar5416Bank3), 3); |
| 174 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6, |
| 175 | ARRAY_SIZE(ar5416Bank6), 3); |
| 176 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC, |
| 177 | ARRAY_SIZE(ar5416Bank6TPC), 3); |
| 178 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7, |
| 179 | ARRAY_SIZE(ar5416Bank7), 2); |
| 180 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, |
| 181 | ARRAY_SIZE(ar5416Addac), 2); |
| 182 | } |
| 183 | } |
| 184 | |
Luis R. Rodriguez | d8f492b | 2010-04-15 17:39:04 -0400 | [diff] [blame] | 185 | /* Support for Japan ch.14 (2484) spread */ |
| 186 | void ar9002_hw_cck_chan14_spread(struct ath_hw *ah) |
| 187 | { |
| 188 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
| 189 | INIT_INI_ARRAY(&ah->iniCckfirNormal, |
Felix Fietkau | f504f5f | 2010-07-02 00:09:47 +0200 | [diff] [blame] | 190 | ar9287Common_normal_cck_fir_coeff_9287_1_1, |
| 191 | ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_9287_1_1), |
Luis R. Rodriguez | d8f492b | 2010-04-15 17:39:04 -0400 | [diff] [blame] | 192 | 2); |
| 193 | INIT_INI_ARRAY(&ah->iniCckfirJapan2484, |
Felix Fietkau | f504f5f | 2010-07-02 00:09:47 +0200 | [diff] [blame] | 194 | ar9287Common_japan_2484_cck_fir_coeff_9287_1_1, |
| 195 | ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_9287_1_1), |
Luis R. Rodriguez | d8f492b | 2010-04-15 17:39:04 -0400 | [diff] [blame] | 196 | 2); |
| 197 | } |
| 198 | } |
| 199 | |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 200 | static void ar9280_20_hw_init_rxgain_ini(struct ath_hw *ah) |
| 201 | { |
| 202 | u32 rxgain_type; |
| 203 | |
| 204 | if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= |
| 205 | AR5416_EEP_MINOR_VER_17) { |
| 206 | rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE); |
| 207 | |
| 208 | if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF) |
| 209 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 210 | ar9280Modes_backoff_13db_rxgain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 211 | ARRAY_SIZE(ar9280Modes_backoff_13db_rxgain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 212 | else if (rxgain_type == AR5416_EEP_RXGAIN_23DB_BACKOFF) |
| 213 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 214 | ar9280Modes_backoff_23db_rxgain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 215 | ARRAY_SIZE(ar9280Modes_backoff_23db_rxgain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 216 | else |
| 217 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 218 | ar9280Modes_original_rxgain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 219 | ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 220 | } else { |
| 221 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 222 | ar9280Modes_original_rxgain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 223 | ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah) |
| 228 | { |
| 229 | u32 txgain_type; |
| 230 | |
| 231 | if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= |
| 232 | AR5416_EEP_MINOR_VER_19) { |
| 233 | txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); |
| 234 | |
| 235 | if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) |
| 236 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 237 | ar9280Modes_high_power_tx_gain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 238 | ARRAY_SIZE(ar9280Modes_high_power_tx_gain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 239 | else |
| 240 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 241 | ar9280Modes_original_tx_gain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 242 | ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 243 | } else { |
| 244 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 245 | ar9280Modes_original_tx_gain_9280_2, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 246 | ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
| 250 | static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah) |
| 251 | { |
| 252 | if (AR_SREV_9287_11_OR_LATER(ah)) |
| 253 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
| 254 | ar9287Modes_rx_gain_9287_1_1, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 255 | ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 256 | else if (AR_SREV_9280_20(ah)) |
| 257 | ar9280_20_hw_init_rxgain_ini(ah); |
| 258 | |
| 259 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
| 260 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 261 | ar9287Modes_tx_gain_9287_1_1, |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 262 | ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 263 | } else if (AR_SREV_9280_20(ah)) { |
| 264 | ar9280_20_hw_init_txgain_ini(ah); |
| 265 | } else if (AR_SREV_9285_12_OR_LATER(ah)) { |
| 266 | u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); |
| 267 | |
| 268 | /* txgain table */ |
| 269 | if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) { |
| 270 | if (AR_SREV_9285E_20(ah)) { |
| 271 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 272 | ar9285Modes_XE2_0_high_power, |
| 273 | ARRAY_SIZE( |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 274 | ar9285Modes_XE2_0_high_power), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 275 | } else { |
| 276 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 277 | ar9285Modes_high_power_tx_gain_9285_1_2, |
| 278 | ARRAY_SIZE( |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 279 | ar9285Modes_high_power_tx_gain_9285_1_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 280 | } |
| 281 | } else { |
| 282 | if (AR_SREV_9285E_20(ah)) { |
| 283 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 284 | ar9285Modes_XE2_0_normal_power, |
| 285 | ARRAY_SIZE( |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 286 | ar9285Modes_XE2_0_normal_power), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 287 | } else { |
| 288 | INIT_INI_ARRAY(&ah->iniModesTxGain, |
| 289 | ar9285Modes_original_tx_gain_9285_1_2, |
| 290 | ARRAY_SIZE( |
Felix Fietkau | b8b0b97 | 2011-08-29 13:39:46 +0200 | [diff] [blame] | 291 | ar9285Modes_original_tx_gain_9285_1_2), 5); |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 297 | /* |
| 298 | * Helper for ASPM support. |
| 299 | * |
| 300 | * Disable PLL when in L0s as well as receiver clock when in L1. |
| 301 | * This power saving option must be enabled through the SerDes. |
| 302 | * |
| 303 | * Programming the SerDes must go through the same 288 bit serial shift |
| 304 | * register as the other analog registers. Hence the 9 writes. |
| 305 | */ |
| 306 | static void ar9002_hw_configpcipowersave(struct ath_hw *ah, |
Stanislaw Gruszka | 84c87dc | 2011-08-05 13:10:32 +0200 | [diff] [blame] | 307 | bool power_off) |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 308 | { |
| 309 | u8 i; |
| 310 | u32 val; |
| 311 | |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 312 | /* Nothing to do on restore for 11N */ |
Stanislaw Gruszka | 84c87dc | 2011-08-05 13:10:32 +0200 | [diff] [blame] | 313 | if (!power_off /* !restore */) { |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 314 | if (AR_SREV_9280_20_OR_LATER(ah)) { |
| 315 | /* |
| 316 | * AR9280 2.0 or later chips use SerDes values from the |
| 317 | * initvals.h initialized depending on chipset during |
| 318 | * __ath9k_hw_init() |
| 319 | */ |
| 320 | for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) { |
| 321 | REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0), |
| 322 | INI_RA(&ah->iniPcieSerdes, i, 1)); |
| 323 | } |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 324 | } else { |
Sujith | d5e347b | 2010-04-23 10:28:11 +0530 | [diff] [blame] | 325 | ENABLE_REGWRITE_BUFFER(ah); |
| 326 | |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 327 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); |
| 328 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); |
| 329 | |
| 330 | /* RX shut off when elecidle is asserted */ |
| 331 | REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039); |
| 332 | REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824); |
| 333 | REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579); |
| 334 | |
| 335 | /* |
| 336 | * Ignore ah->ah_config.pcie_clock_req setting for |
| 337 | * pre-AR9280 11n |
| 338 | */ |
| 339 | REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff); |
| 340 | |
| 341 | REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); |
| 342 | REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); |
| 343 | REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007); |
| 344 | |
| 345 | /* Load the new settings */ |
| 346 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); |
Sujith | d5e347b | 2010-04-23 10:28:11 +0530 | [diff] [blame] | 347 | |
| 348 | REGWRITE_BUFFER_FLUSH(ah); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | udelay(1000); |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 352 | } |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 353 | |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 354 | if (power_off) { |
| 355 | /* clear bit 19 to disable L1 */ |
| 356 | REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 357 | |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 358 | val = REG_READ(ah, AR_WA); |
| 359 | |
| 360 | /* |
| 361 | * Set PCIe workaround bits |
| 362 | * In AR9280 and AR9285, bit 14 in WA register (disable L1) |
| 363 | * should only be set when device enters D3 and be |
| 364 | * cleared when device comes back to D0. |
| 365 | */ |
| 366 | if (ah->config.pcie_waen) { |
| 367 | if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE) |
| 368 | val |= AR_WA_D3_L1_DISABLE; |
| 369 | } else { |
| 370 | if (((AR_SREV_9285(ah) || |
| 371 | AR_SREV_9271(ah) || |
| 372 | AR_SREV_9287(ah)) && |
| 373 | (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) || |
| 374 | (AR_SREV_9280(ah) && |
| 375 | (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) { |
| 376 | val |= AR_WA_D3_L1_DISABLE; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if (AR_SREV_9280(ah) || AR_SREV_9285(ah) || AR_SREV_9287(ah)) { |
| 381 | /* |
| 382 | * Disable bit 6 and 7 before entering D3 to |
| 383 | * prevent system hang. |
| 384 | */ |
| 385 | val &= ~(AR_WA_BIT6 | AR_WA_BIT7); |
| 386 | } |
| 387 | |
Vasanthakumar Thiagarajan | f119da3 | 2010-11-04 17:41:25 -0700 | [diff] [blame] | 388 | if (AR_SREV_9280(ah)) |
| 389 | val |= AR_WA_BIT22; |
| 390 | |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 391 | if (AR_SREV_9285E_20(ah)) |
| 392 | val |= AR_WA_BIT23; |
| 393 | |
| 394 | REG_WRITE(ah, AR_WA, val); |
| 395 | } else { |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 396 | if (ah->config.pcie_waen) { |
| 397 | val = ah->config.pcie_waen; |
| 398 | if (!power_off) |
| 399 | val &= (~AR_WA_D3_L1_DISABLE); |
| 400 | } else { |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 401 | if (AR_SREV_9285(ah) || |
| 402 | AR_SREV_9271(ah) || |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 403 | AR_SREV_9287(ah)) { |
| 404 | val = AR9285_WA_DEFAULT; |
| 405 | if (!power_off) |
| 406 | val &= (~AR_WA_D3_L1_DISABLE); |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 407 | } |
| 408 | else if (AR_SREV_9280(ah)) { |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 409 | /* |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 410 | * For AR9280 chips, bit 22 of 0x4004 |
| 411 | * needs to be set. |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 412 | */ |
| 413 | val = AR9280_WA_DEFAULT; |
| 414 | if (!power_off) |
| 415 | val &= (~AR_WA_D3_L1_DISABLE); |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 416 | } else { |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 417 | val = AR_WA_DEFAULT; |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 418 | } |
| 419 | } |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 420 | |
| 421 | /* WAR for ASPM system hang */ |
Rajkumar Manoharan | 5b64aa7 | 2011-01-27 18:39:37 +0530 | [diff] [blame] | 422 | if (AR_SREV_9285(ah) || AR_SREV_9287(ah)) |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 423 | val |= (AR_WA_BIT6 | AR_WA_BIT7); |
Sujith | 15ae733 | 2010-06-01 15:14:09 +0530 | [diff] [blame] | 424 | |
| 425 | if (AR_SREV_9285E_20(ah)) |
| 426 | val |= AR_WA_BIT23; |
| 427 | |
| 428 | REG_WRITE(ah, AR_WA, val); |
| 429 | |
| 430 | /* set bit 19 to allow forcing of pcie core into L1 state */ |
| 431 | REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 432 | } |
| 433 | } |
| 434 | |
Luis R. Rodriguez | ebd5a14 | 2010-04-15 17:39:18 -0400 | [diff] [blame] | 435 | static int ar9002_hw_get_radiorev(struct ath_hw *ah) |
| 436 | { |
| 437 | u32 val; |
| 438 | int i; |
| 439 | |
Sujith | 7d0d0df | 2010-04-16 11:53:57 +0530 | [diff] [blame] | 440 | ENABLE_REGWRITE_BUFFER(ah); |
Luis R. Rodriguez | ebd5a14 | 2010-04-15 17:39:18 -0400 | [diff] [blame] | 441 | |
Sujith | 7d0d0df | 2010-04-16 11:53:57 +0530 | [diff] [blame] | 442 | REG_WRITE(ah, AR_PHY(0x36), 0x00007058); |
Luis R. Rodriguez | ebd5a14 | 2010-04-15 17:39:18 -0400 | [diff] [blame] | 443 | for (i = 0; i < 8; i++) |
| 444 | REG_WRITE(ah, AR_PHY(0x20), 0x00010000); |
Sujith | 7d0d0df | 2010-04-16 11:53:57 +0530 | [diff] [blame] | 445 | |
| 446 | REGWRITE_BUFFER_FLUSH(ah); |
Sujith | 7d0d0df | 2010-04-16 11:53:57 +0530 | [diff] [blame] | 447 | |
Luis R. Rodriguez | ebd5a14 | 2010-04-15 17:39:18 -0400 | [diff] [blame] | 448 | val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff; |
| 449 | val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4); |
| 450 | |
| 451 | return ath9k_hw_reverse_bits(val, 8); |
| 452 | } |
| 453 | |
| 454 | int ar9002_hw_rf_claim(struct ath_hw *ah) |
| 455 | { |
| 456 | u32 val; |
| 457 | |
| 458 | REG_WRITE(ah, AR_PHY(0), 0x00000007); |
| 459 | |
| 460 | val = ar9002_hw_get_radiorev(ah); |
| 461 | switch (val & AR_RADIO_SREV_MAJOR) { |
| 462 | case 0: |
| 463 | val = AR_RAD5133_SREV_MAJOR; |
| 464 | break; |
| 465 | case AR_RAD5133_SREV_MAJOR: |
| 466 | case AR_RAD5122_SREV_MAJOR: |
| 467 | case AR_RAD2133_SREV_MAJOR: |
| 468 | case AR_RAD2122_SREV_MAJOR: |
| 469 | break; |
| 470 | default: |
Joe Perches | 3800276 | 2010-12-02 19:12:36 -0800 | [diff] [blame] | 471 | ath_err(ath9k_hw_common(ah), |
| 472 | "Radio Chip Rev 0x%02X not supported\n", |
| 473 | val & AR_RADIO_SREV_MAJOR); |
Luis R. Rodriguez | ebd5a14 | 2010-04-15 17:39:18 -0400 | [diff] [blame] | 474 | return -EOPNOTSUPP; |
| 475 | } |
| 476 | |
| 477 | ah->hw_version.analog5GhzRev = val; |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
Sujith | e9141f7 | 2010-06-01 15:14:10 +0530 | [diff] [blame] | 482 | void ar9002_hw_enable_async_fifo(struct ath_hw *ah) |
| 483 | { |
| 484 | if (AR_SREV_9287_13_OR_LATER(ah)) { |
| 485 | REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, |
| 486 | AR_MAC_PCU_ASYNC_FIFO_REG3_DATAPATH_SEL); |
| 487 | REG_SET_BIT(ah, AR_PHY_MODE, AR_PHY_MODE_ASYNCFIFO); |
| 488 | REG_CLR_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, |
| 489 | AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET); |
| 490 | REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, |
| 491 | AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET); |
| 492 | } |
| 493 | } |
| 494 | |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 495 | /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */ |
| 496 | void ar9002_hw_attach_ops(struct ath_hw *ah) |
| 497 | { |
| 498 | struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); |
| 499 | struct ath_hw_ops *ops = ath9k_hw_ops(ah); |
| 500 | |
| 501 | priv_ops->init_mode_regs = ar9002_hw_init_mode_regs; |
Luis R. Rodriguez | 991312d | 2010-04-15 17:39:05 -0400 | [diff] [blame] | 502 | priv_ops->init_mode_gain_regs = ar9002_hw_init_mode_gain_regs; |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 503 | |
| 504 | ops->config_pci_powersave = ar9002_hw_configpcipowersave; |
| 505 | |
| 506 | ar5008_hw_attach_phy_ops(ah); |
Felix Fietkau | 7a37081 | 2010-09-22 12:34:52 +0200 | [diff] [blame] | 507 | if (AR_SREV_9280_20_OR_LATER(ah)) |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 508 | ar9002_hw_attach_phy_ops(ah); |
| 509 | |
| 510 | ar9002_hw_attach_calib_ops(ah); |
| 511 | ar9002_hw_attach_mac_ops(ah); |
Luis R. Rodriguez | b3950e6 | 2010-04-15 17:39:03 -0400 | [diff] [blame] | 512 | } |
Rajkumar Manoharan | c2ba334 | 2010-09-03 16:00:00 +0530 | [diff] [blame] | 513 | |
| 514 | void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan) |
| 515 | { |
| 516 | u32 modesIndex; |
| 517 | int i; |
| 518 | |
| 519 | switch (chan->chanmode) { |
| 520 | case CHANNEL_A: |
| 521 | case CHANNEL_A_HT20: |
| 522 | modesIndex = 1; |
| 523 | break; |
| 524 | case CHANNEL_A_HT40PLUS: |
| 525 | case CHANNEL_A_HT40MINUS: |
| 526 | modesIndex = 2; |
| 527 | break; |
| 528 | case CHANNEL_G: |
| 529 | case CHANNEL_G_HT20: |
| 530 | case CHANNEL_B: |
| 531 | modesIndex = 4; |
| 532 | break; |
| 533 | case CHANNEL_G_HT40PLUS: |
| 534 | case CHANNEL_G_HT40MINUS: |
| 535 | modesIndex = 3; |
| 536 | break; |
| 537 | |
| 538 | default: |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | ENABLE_REGWRITE_BUFFER(ah); |
| 543 | |
| 544 | for (i = 0; i < ah->iniModes_9271_ANI_reg.ia_rows; i++) { |
| 545 | u32 reg = INI_RA(&ah->iniModes_9271_ANI_reg, i, 0); |
| 546 | u32 val = INI_RA(&ah->iniModes_9271_ANI_reg, i, modesIndex); |
| 547 | u32 val_orig; |
| 548 | |
| 549 | if (reg == AR_PHY_CCK_DETECT) { |
| 550 | val_orig = REG_READ(ah, reg); |
| 551 | val &= AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK; |
| 552 | val_orig &= ~AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK; |
| 553 | |
| 554 | REG_WRITE(ah, reg, val|val_orig); |
| 555 | } else |
| 556 | REG_WRITE(ah, reg, val); |
| 557 | } |
| 558 | |
| 559 | REGWRITE_BUFFER_FLUSH(ah); |
Rajkumar Manoharan | c2ba334 | 2010-09-03 16:00:00 +0530 | [diff] [blame] | 560 | } |