2 * Copyright (c) 2008-2010 Atheros Communications Inc.
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.
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.
18 #include "ar5008_initvals.h"
19 #include "ar9001_initvals.h"
20 #include "ar9002_initvals.h"
21 #include "ar9002_phy.h"
23 /* General hardware code for the A5008/AR9001/AR9002 hadware families */
25 static bool ar9002_hw_macversion_supported(u32 macversion)
28 case AR_SREV_VERSION_5416_PCI:
29 case AR_SREV_VERSION_5416_PCIE:
30 case AR_SREV_VERSION_9160:
31 case AR_SREV_VERSION_9100:
32 case AR_SREV_VERSION_9280:
33 case AR_SREV_VERSION_9285:
34 case AR_SREV_VERSION_9287:
35 case AR_SREV_VERSION_9271:
43 static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
45 if (AR_SREV_9271(ah)) {
46 INIT_INI_ARRAY(&ah->iniModes, ar9271Modes_9271,
47 ARRAY_SIZE(ar9271Modes_9271), 6);
48 INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271,
49 ARRAY_SIZE(ar9271Common_9271), 2);
50 INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271,
51 ar9271Common_normal_cck_fir_coeff_9271,
52 ARRAY_SIZE(ar9271Common_normal_cck_fir_coeff_9271), 2);
53 INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271,
54 ar9271Common_japan_2484_cck_fir_coeff_9271,
55 ARRAY_SIZE(ar9271Common_japan_2484_cck_fir_coeff_9271), 2);
56 INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only,
57 ar9271Modes_9271_1_0_only,
58 ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6);
59 INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg,
60 ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 6);
61 INIT_INI_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
62 ar9271Modes_high_power_tx_gain_9271,
63 ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 6);
64 INIT_INI_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
65 ar9271Modes_normal_power_tx_gain_9271,
66 ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 6);
70 if (AR_SREV_9287_11_OR_LATER(ah)) {
71 INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1,
72 ARRAY_SIZE(ar9287Modes_9287_1_1), 6);
73 INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1,
74 ARRAY_SIZE(ar9287Common_9287_1_1), 2);
75 if (ah->config.pcie_clock_req)
76 INIT_INI_ARRAY(&ah->iniPcieSerdes,
77 ar9287PciePhy_clkreq_off_L1_9287_1_1,
78 ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_1), 2);
80 INIT_INI_ARRAY(&ah->iniPcieSerdes,
81 ar9287PciePhy_clkreq_always_on_L1_9287_1_1,
82 ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_1),
84 } else if (AR_SREV_9287_10_OR_LATER(ah)) {
85 INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_0,
86 ARRAY_SIZE(ar9287Modes_9287_1_0), 6);
87 INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_0,
88 ARRAY_SIZE(ar9287Common_9287_1_0), 2);
90 if (ah->config.pcie_clock_req)
91 INIT_INI_ARRAY(&ah->iniPcieSerdes,
92 ar9287PciePhy_clkreq_off_L1_9287_1_0,
93 ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_0), 2);
95 INIT_INI_ARRAY(&ah->iniPcieSerdes,
96 ar9287PciePhy_clkreq_always_on_L1_9287_1_0,
97 ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_0),
99 } else if (AR_SREV_9285_12_OR_LATER(ah)) {
102 INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2,
103 ARRAY_SIZE(ar9285Modes_9285_1_2), 6);
104 INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2,
105 ARRAY_SIZE(ar9285Common_9285_1_2), 2);
107 if (ah->config.pcie_clock_req) {
108 INIT_INI_ARRAY(&ah->iniPcieSerdes,
109 ar9285PciePhy_clkreq_off_L1_9285_1_2,
110 ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285_1_2), 2);
112 INIT_INI_ARRAY(&ah->iniPcieSerdes,
113 ar9285PciePhy_clkreq_always_on_L1_9285_1_2,
114 ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285_1_2),
117 } else if (AR_SREV_9285_10_OR_LATER(ah)) {
118 INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285,
119 ARRAY_SIZE(ar9285Modes_9285), 6);
120 INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285,
121 ARRAY_SIZE(ar9285Common_9285), 2);
123 if (ah->config.pcie_clock_req) {
124 INIT_INI_ARRAY(&ah->iniPcieSerdes,
125 ar9285PciePhy_clkreq_off_L1_9285,
126 ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285), 2);
128 INIT_INI_ARRAY(&ah->iniPcieSerdes,
129 ar9285PciePhy_clkreq_always_on_L1_9285,
130 ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285), 2);
132 } else if (AR_SREV_9280_20_OR_LATER(ah)) {
133 INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2,
134 ARRAY_SIZE(ar9280Modes_9280_2), 6);
135 INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2,
136 ARRAY_SIZE(ar9280Common_9280_2), 2);
138 if (ah->config.pcie_clock_req) {
139 INIT_INI_ARRAY(&ah->iniPcieSerdes,
140 ar9280PciePhy_clkreq_off_L1_9280,
141 ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280), 2);
143 INIT_INI_ARRAY(&ah->iniPcieSerdes,
144 ar9280PciePhy_clkreq_always_on_L1_9280,
145 ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2);
147 INIT_INI_ARRAY(&ah->iniModesAdditional,
148 ar9280Modes_fast_clock_9280_2,
149 ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3);
150 } else if (AR_SREV_9280_10_OR_LATER(ah)) {
151 INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280,
152 ARRAY_SIZE(ar9280Modes_9280), 6);
153 INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280,
154 ARRAY_SIZE(ar9280Common_9280), 2);
155 } else if (AR_SREV_9160_10_OR_LATER(ah)) {
156 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160,
157 ARRAY_SIZE(ar5416Modes_9160), 6);
158 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160,
159 ARRAY_SIZE(ar5416Common_9160), 2);
160 INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9160,
161 ARRAY_SIZE(ar5416Bank0_9160), 2);
162 INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9160,
163 ARRAY_SIZE(ar5416BB_RfGain_9160), 3);
164 INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9160,
165 ARRAY_SIZE(ar5416Bank1_9160), 2);
166 INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9160,
167 ARRAY_SIZE(ar5416Bank2_9160), 2);
168 INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9160,
169 ARRAY_SIZE(ar5416Bank3_9160), 3);
170 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9160,
171 ARRAY_SIZE(ar5416Bank6_9160), 3);
172 INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9160,
173 ARRAY_SIZE(ar5416Bank6TPC_9160), 3);
174 INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9160,
175 ARRAY_SIZE(ar5416Bank7_9160), 2);
176 if (AR_SREV_9160_11(ah)) {
177 INIT_INI_ARRAY(&ah->iniAddac,
179 ARRAY_SIZE(ar5416Addac_91601_1), 2);
181 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160,
182 ARRAY_SIZE(ar5416Addac_9160), 2);
184 } else if (AR_SREV_9100_OR_LATER(ah)) {
185 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100,
186 ARRAY_SIZE(ar5416Modes_9100), 6);
187 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100,
188 ARRAY_SIZE(ar5416Common_9100), 2);
189 INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9100,
190 ARRAY_SIZE(ar5416Bank0_9100), 2);
191 INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9100,
192 ARRAY_SIZE(ar5416BB_RfGain_9100), 3);
193 INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9100,
194 ARRAY_SIZE(ar5416Bank1_9100), 2);
195 INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9100,
196 ARRAY_SIZE(ar5416Bank2_9100), 2);
197 INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9100,
198 ARRAY_SIZE(ar5416Bank3_9100), 3);
199 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100,
200 ARRAY_SIZE(ar5416Bank6_9100), 3);
201 INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100,
202 ARRAY_SIZE(ar5416Bank6TPC_9100), 3);
203 INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9100,
204 ARRAY_SIZE(ar5416Bank7_9100), 2);
205 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100,
206 ARRAY_SIZE(ar5416Addac_9100), 2);
208 INIT_INI_ARRAY(&ah->iniModes, ar5416Modes,
209 ARRAY_SIZE(ar5416Modes), 6);
210 INIT_INI_ARRAY(&ah->iniCommon, ar5416Common,
211 ARRAY_SIZE(ar5416Common), 2);
212 INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0,
213 ARRAY_SIZE(ar5416Bank0), 2);
214 INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain,
215 ARRAY_SIZE(ar5416BB_RfGain), 3);
216 INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1,
217 ARRAY_SIZE(ar5416Bank1), 2);
218 INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2,
219 ARRAY_SIZE(ar5416Bank2), 2);
220 INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3,
221 ARRAY_SIZE(ar5416Bank3), 3);
222 INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6,
223 ARRAY_SIZE(ar5416Bank6), 3);
224 INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC,
225 ARRAY_SIZE(ar5416Bank6TPC), 3);
226 INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7,
227 ARRAY_SIZE(ar5416Bank7), 2);
228 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac,
229 ARRAY_SIZE(ar5416Addac), 2);
233 /* Support for Japan ch.14 (2484) spread */
234 void ar9002_hw_cck_chan14_spread(struct ath_hw *ah)
236 if (AR_SREV_9287_11_OR_LATER(ah)) {
237 INIT_INI_ARRAY(&ah->iniCckfirNormal,
238 ar9287Common_normal_cck_fir_coeff_92871_1,
239 ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_92871_1),
241 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
242 ar9287Common_japan_2484_cck_fir_coeff_92871_1,
243 ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_92871_1),
248 static void ar9280_20_hw_init_rxgain_ini(struct ath_hw *ah)
252 if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >=
253 AR5416_EEP_MINOR_VER_17) {
254 rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE);
256 if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF)
257 INIT_INI_ARRAY(&ah->iniModesRxGain,
258 ar9280Modes_backoff_13db_rxgain_9280_2,
259 ARRAY_SIZE(ar9280Modes_backoff_13db_rxgain_9280_2), 6);
260 else if (rxgain_type == AR5416_EEP_RXGAIN_23DB_BACKOFF)
261 INIT_INI_ARRAY(&ah->iniModesRxGain,
262 ar9280Modes_backoff_23db_rxgain_9280_2,
263 ARRAY_SIZE(ar9280Modes_backoff_23db_rxgain_9280_2), 6);
265 INIT_INI_ARRAY(&ah->iniModesRxGain,
266 ar9280Modes_original_rxgain_9280_2,
267 ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6);
269 INIT_INI_ARRAY(&ah->iniModesRxGain,
270 ar9280Modes_original_rxgain_9280_2,
271 ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6);
275 static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah)
279 if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >=
280 AR5416_EEP_MINOR_VER_19) {
281 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE);
283 if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER)
284 INIT_INI_ARRAY(&ah->iniModesTxGain,
285 ar9280Modes_high_power_tx_gain_9280_2,
286 ARRAY_SIZE(ar9280Modes_high_power_tx_gain_9280_2), 6);
288 INIT_INI_ARRAY(&ah->iniModesTxGain,
289 ar9280Modes_original_tx_gain_9280_2,
290 ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6);
292 INIT_INI_ARRAY(&ah->iniModesTxGain,
293 ar9280Modes_original_tx_gain_9280_2,
294 ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6);
298 static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah)
300 if (AR_SREV_9287_11_OR_LATER(ah))
301 INIT_INI_ARRAY(&ah->iniModesRxGain,
302 ar9287Modes_rx_gain_9287_1_1,
303 ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 6);
304 else if (AR_SREV_9287_10(ah))
305 INIT_INI_ARRAY(&ah->iniModesRxGain,
306 ar9287Modes_rx_gain_9287_1_0,
307 ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_0), 6);
308 else if (AR_SREV_9280_20(ah))
309 ar9280_20_hw_init_rxgain_ini(ah);
311 if (AR_SREV_9287_11_OR_LATER(ah)) {
312 INIT_INI_ARRAY(&ah->iniModesTxGain,
313 ar9287Modes_tx_gain_9287_1_1,
314 ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 6);
315 } else if (AR_SREV_9287_10(ah)) {
316 INIT_INI_ARRAY(&ah->iniModesTxGain,
317 ar9287Modes_tx_gain_9287_1_0,
318 ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_0), 6);
319 } else if (AR_SREV_9280_20(ah)) {
320 ar9280_20_hw_init_txgain_ini(ah);
321 } else if (AR_SREV_9285_12_OR_LATER(ah)) {
322 u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE);
325 if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) {
326 if (AR_SREV_9285E_20(ah)) {
327 INIT_INI_ARRAY(&ah->iniModesTxGain,
328 ar9285Modes_XE2_0_high_power,
330 ar9285Modes_XE2_0_high_power), 6);
332 INIT_INI_ARRAY(&ah->iniModesTxGain,
333 ar9285Modes_high_power_tx_gain_9285_1_2,
335 ar9285Modes_high_power_tx_gain_9285_1_2), 6);
338 if (AR_SREV_9285E_20(ah)) {
339 INIT_INI_ARRAY(&ah->iniModesTxGain,
340 ar9285Modes_XE2_0_normal_power,
342 ar9285Modes_XE2_0_normal_power), 6);
344 INIT_INI_ARRAY(&ah->iniModesTxGain,
345 ar9285Modes_original_tx_gain_9285_1_2,
347 ar9285Modes_original_tx_gain_9285_1_2), 6);
354 * Helper for ASPM support.
356 * Disable PLL when in L0s as well as receiver clock when in L1.
357 * This power saving option must be enabled through the SerDes.
359 * Programming the SerDes must go through the same 288 bit serial shift
360 * register as the other analog registers. Hence the 9 writes.
362 static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
369 if (ah->is_pciexpress != true)
372 /* Do not touch SerDes registers */
373 if (ah->config.pcie_powersave_enable == 2)
376 /* Nothing to do on restore for 11N */
378 if (AR_SREV_9280_20_OR_LATER(ah)) {
380 * AR9280 2.0 or later chips use SerDes values from the
381 * initvals.h initialized depending on chipset during
384 for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) {
385 REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0),
386 INI_RA(&ah->iniPcieSerdes, i, 1));
388 } else if (AR_SREV_9280(ah) &&
389 (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) {
390 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
391 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
393 /* RX shut off when elecidle is asserted */
394 REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019);
395 REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820);
396 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560);
398 /* Shut off CLKREQ active in L1 */
399 if (ah->config.pcie_clock_req)
400 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc);
402 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd);
404 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
405 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
406 REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007);
408 /* Load the new settings */
409 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
412 ENABLE_REGWRITE_BUFFER(ah);
414 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
415 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
417 /* RX shut off when elecidle is asserted */
418 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039);
419 REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824);
420 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579);
423 * Ignore ah->ah_config.pcie_clock_req setting for
426 REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff);
428 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
429 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
430 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007);
432 /* Load the new settings */
433 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
435 REGWRITE_BUFFER_FLUSH(ah);
436 DISABLE_REGWRITE_BUFFER(ah);
443 /* clear bit 19 to disable L1 */
444 REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
446 val = REG_READ(ah, AR_WA);
449 * Set PCIe workaround bits
450 * In AR9280 and AR9285, bit 14 in WA register (disable L1)
451 * should only be set when device enters D3 and be
452 * cleared when device comes back to D0.
454 if (ah->config.pcie_waen) {
455 if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE)
456 val |= AR_WA_D3_L1_DISABLE;
458 if (((AR_SREV_9285(ah) ||
461 (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) ||
463 (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) {
464 val |= AR_WA_D3_L1_DISABLE;
468 if (AR_SREV_9280(ah) || AR_SREV_9285(ah) || AR_SREV_9287(ah)) {
470 * Disable bit 6 and 7 before entering D3 to
471 * prevent system hang.
473 val &= ~(AR_WA_BIT6 | AR_WA_BIT7);
476 if (AR_SREV_9285E_20(ah))
479 REG_WRITE(ah, AR_WA, val);
481 if (ah->config.pcie_waen) {
482 val = ah->config.pcie_waen;
484 val &= (~AR_WA_D3_L1_DISABLE);
486 if (AR_SREV_9285(ah) ||
489 val = AR9285_WA_DEFAULT;
491 val &= (~AR_WA_D3_L1_DISABLE);
493 else if (AR_SREV_9280(ah)) {
495 * For AR9280 chips, bit 22 of 0x4004
498 val = AR9280_WA_DEFAULT;
500 val &= (~AR_WA_D3_L1_DISABLE);
506 /* WAR for ASPM system hang */
507 if (AR_SREV_9280(ah) || AR_SREV_9285(ah) || AR_SREV_9287(ah)) {
508 val |= (AR_WA_BIT6 | AR_WA_BIT7);
511 if (AR_SREV_9285E_20(ah))
514 REG_WRITE(ah, AR_WA, val);
516 /* set bit 19 to allow forcing of pcie core into L1 state */
517 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
521 static int ar9002_hw_get_radiorev(struct ath_hw *ah)
526 ENABLE_REGWRITE_BUFFER(ah);
528 REG_WRITE(ah, AR_PHY(0x36), 0x00007058);
529 for (i = 0; i < 8; i++)
530 REG_WRITE(ah, AR_PHY(0x20), 0x00010000);
532 REGWRITE_BUFFER_FLUSH(ah);
533 DISABLE_REGWRITE_BUFFER(ah);
535 val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff;
536 val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4);
538 return ath9k_hw_reverse_bits(val, 8);
541 int ar9002_hw_rf_claim(struct ath_hw *ah)
545 REG_WRITE(ah, AR_PHY(0), 0x00000007);
547 val = ar9002_hw_get_radiorev(ah);
548 switch (val & AR_RADIO_SREV_MAJOR) {
550 val = AR_RAD5133_SREV_MAJOR;
552 case AR_RAD5133_SREV_MAJOR:
553 case AR_RAD5122_SREV_MAJOR:
554 case AR_RAD2133_SREV_MAJOR:
555 case AR_RAD2122_SREV_MAJOR:
558 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
559 "Radio Chip Rev 0x%02X not supported\n",
560 val & AR_RADIO_SREV_MAJOR);
564 ah->hw_version.analog5GhzRev = val;
569 void ar9002_hw_enable_async_fifo(struct ath_hw *ah)
571 if (AR_SREV_9287_13_OR_LATER(ah)) {
572 REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3,
573 AR_MAC_PCU_ASYNC_FIFO_REG3_DATAPATH_SEL);
574 REG_SET_BIT(ah, AR_PHY_MODE, AR_PHY_MODE_ASYNCFIFO);
575 REG_CLR_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3,
576 AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET);
577 REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3,
578 AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET);
583 * If Async FIFO is enabled, the following counters change as MAC now runs
584 * at 117 Mhz instead of 88/44MHz when async FIFO is disabled.
586 * The values below tested for ht40 2 chain.
587 * Overwrite the delay/timeouts initialized in process ini.
589 void ar9002_hw_update_async_fifo(struct ath_hw *ah)
591 if (AR_SREV_9287_13_OR_LATER(ah)) {
592 REG_WRITE(ah, AR_D_GBL_IFS_SIFS,
593 AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR);
594 REG_WRITE(ah, AR_D_GBL_IFS_SLOT,
595 AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR);
596 REG_WRITE(ah, AR_D_GBL_IFS_EIFS,
597 AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR);
599 REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR);
600 REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR);
602 REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER,
603 AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768);
604 REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN,
605 AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL);
610 * We don't enable WEP aggregation on mac80211 but we keep this
611 * around for HAL unification purposes.
613 void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah)
615 if (AR_SREV_9287_13_OR_LATER(ah)) {
616 REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
617 AR_PCU_MISC_MODE2_ENABLE_AGGWEP);
621 /* Sets up the AR5008/AR9001/AR9002 hardware familiy callbacks */
622 void ar9002_hw_attach_ops(struct ath_hw *ah)
624 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
625 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
627 priv_ops->init_mode_regs = ar9002_hw_init_mode_regs;
628 priv_ops->init_mode_gain_regs = ar9002_hw_init_mode_gain_regs;
629 priv_ops->macversion_supported = ar9002_hw_macversion_supported;
631 ops->config_pci_powersave = ar9002_hw_configpcipowersave;
633 ar5008_hw_attach_phy_ops(ah);
634 if (AR_SREV_9280_10_OR_LATER(ah))
635 ar9002_hw_attach_phy_ops(ah);
637 ar9002_hw_attach_calib_ops(ah);
638 ar9002_hw_attach_mac_ops(ah);
640 ath9k_hw_attach_ani_ops_old(ah);