diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hw.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 1786 |
1 files changed, 381 insertions, 1405 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index af730c7d50e6..559019262d30 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2008-2009 Atheros Communications Inc. | 2 | * Copyright (c) 2008-2010 Atheros Communications Inc. |
3 | * | 3 | * |
4 | * Permission to use, copy, modify, and/or distribute this software for any | 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 | 5 | * purpose with or without fee is hereby granted, provided that the above |
@@ -19,15 +19,16 @@ | |||
19 | #include <asm/unaligned.h> | 19 | #include <asm/unaligned.h> |
20 | 20 | ||
21 | #include "hw.h" | 21 | #include "hw.h" |
22 | #include "hw-ops.h" | ||
22 | #include "rc.h" | 23 | #include "rc.h" |
23 | #include "initvals.h" | 24 | #include "ar9003_mac.h" |
24 | 25 | ||
25 | #define ATH9K_CLOCK_RATE_CCK 22 | 26 | #define ATH9K_CLOCK_RATE_CCK 22 |
26 | #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 | 27 | #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 |
27 | #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 | 28 | #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 |
29 | #define ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM 44 | ||
28 | 30 | ||
29 | static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type); | 31 | static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type); |
30 | static void ath9k_hw_set_regs(struct ath_hw *ah, struct ath9k_channel *chan); | ||
31 | 32 | ||
32 | MODULE_AUTHOR("Atheros Communications"); | 33 | MODULE_AUTHOR("Atheros Communications"); |
33 | MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards."); | 34 | MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards."); |
@@ -46,6 +47,39 @@ static void __exit ath9k_exit(void) | |||
46 | } | 47 | } |
47 | module_exit(ath9k_exit); | 48 | module_exit(ath9k_exit); |
48 | 49 | ||
50 | /* Private hardware callbacks */ | ||
51 | |||
52 | static void ath9k_hw_init_cal_settings(struct ath_hw *ah) | ||
53 | { | ||
54 | ath9k_hw_private_ops(ah)->init_cal_settings(ah); | ||
55 | } | ||
56 | |||
57 | static void ath9k_hw_init_mode_regs(struct ath_hw *ah) | ||
58 | { | ||
59 | ath9k_hw_private_ops(ah)->init_mode_regs(ah); | ||
60 | } | ||
61 | |||
62 | static bool ath9k_hw_macversion_supported(struct ath_hw *ah) | ||
63 | { | ||
64 | struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); | ||
65 | |||
66 | return priv_ops->macversion_supported(ah->hw_version.macVersion); | ||
67 | } | ||
68 | |||
69 | static u32 ath9k_hw_compute_pll_control(struct ath_hw *ah, | ||
70 | struct ath9k_channel *chan) | ||
71 | { | ||
72 | return ath9k_hw_private_ops(ah)->compute_pll_control(ah, chan); | ||
73 | } | ||
74 | |||
75 | static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah) | ||
76 | { | ||
77 | if (!ath9k_hw_private_ops(ah)->init_mode_gain_regs) | ||
78 | return; | ||
79 | |||
80 | ath9k_hw_private_ops(ah)->init_mode_gain_regs(ah); | ||
81 | } | ||
82 | |||
49 | /********************/ | 83 | /********************/ |
50 | /* Helper Functions */ | 84 | /* Helper Functions */ |
51 | /********************/ | 85 | /********************/ |
@@ -58,7 +92,11 @@ static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs) | |||
58 | return usecs *ATH9K_CLOCK_RATE_CCK; | 92 | return usecs *ATH9K_CLOCK_RATE_CCK; |
59 | if (conf->channel->band == IEEE80211_BAND_2GHZ) | 93 | if (conf->channel->band == IEEE80211_BAND_2GHZ) |
60 | return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM; | 94 | return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM; |
61 | return usecs *ATH9K_CLOCK_RATE_5GHZ_OFDM; | 95 | |
96 | if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK) | ||
97 | return usecs * ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM; | ||
98 | else | ||
99 | return usecs * ATH9K_CLOCK_RATE_5GHZ_OFDM; | ||
62 | } | 100 | } |
63 | 101 | ||
64 | static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs) | 102 | static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs) |
@@ -233,21 +271,6 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah) | |||
233 | } | 271 | } |
234 | } | 272 | } |
235 | 273 | ||
236 | static int ath9k_hw_get_radiorev(struct ath_hw *ah) | ||
237 | { | ||
238 | u32 val; | ||
239 | int i; | ||
240 | |||
241 | REG_WRITE(ah, AR_PHY(0x36), 0x00007058); | ||
242 | |||
243 | for (i = 0; i < 8; i++) | ||
244 | REG_WRITE(ah, AR_PHY(0x20), 0x00010000); | ||
245 | val = (REG_READ(ah, AR_PHY(256)) >> 24) & 0xff; | ||
246 | val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4); | ||
247 | |||
248 | return ath9k_hw_reverse_bits(val, 8); | ||
249 | } | ||
250 | |||
251 | /************************************/ | 274 | /************************************/ |
252 | /* HW Attach, Detach, Init Routines */ | 275 | /* HW Attach, Detach, Init Routines */ |
253 | /************************************/ | 276 | /************************************/ |
@@ -257,6 +280,8 @@ static void ath9k_hw_disablepcie(struct ath_hw *ah) | |||
257 | if (AR_SREV_9100(ah)) | 280 | if (AR_SREV_9100(ah)) |
258 | return; | 281 | return; |
259 | 282 | ||
283 | ENABLE_REGWRITE_BUFFER(ah); | ||
284 | |||
260 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); | 285 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); |
261 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); | 286 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); |
262 | REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029); | 287 | REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029); |
@@ -268,20 +293,30 @@ static void ath9k_hw_disablepcie(struct ath_hw *ah) | |||
268 | REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007); | 293 | REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007); |
269 | 294 | ||
270 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); | 295 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); |
296 | |||
297 | REGWRITE_BUFFER_FLUSH(ah); | ||
298 | DISABLE_REGWRITE_BUFFER(ah); | ||
271 | } | 299 | } |
272 | 300 | ||
301 | /* This should work for all families including legacy */ | ||
273 | static bool ath9k_hw_chip_test(struct ath_hw *ah) | 302 | static bool ath9k_hw_chip_test(struct ath_hw *ah) |
274 | { | 303 | { |
275 | struct ath_common *common = ath9k_hw_common(ah); | 304 | struct ath_common *common = ath9k_hw_common(ah); |
276 | u32 regAddr[2] = { AR_STA_ID0, AR_PHY_BASE + (8 << 2) }; | 305 | u32 regAddr[2] = { AR_STA_ID0 }; |
277 | u32 regHold[2]; | 306 | u32 regHold[2]; |
278 | u32 patternData[4] = { 0x55555555, | 307 | u32 patternData[4] = { 0x55555555, |
279 | 0xaaaaaaaa, | 308 | 0xaaaaaaaa, |
280 | 0x66666666, | 309 | 0x66666666, |
281 | 0x99999999 }; | 310 | 0x99999999 }; |
282 | int i, j; | 311 | int i, j, loop_max; |
283 | 312 | ||
284 | for (i = 0; i < 2; i++) { | 313 | if (!AR_SREV_9300_20_OR_LATER(ah)) { |
314 | loop_max = 2; | ||
315 | regAddr[1] = AR_PHY_BASE + (8 << 2); | ||
316 | } else | ||
317 | loop_max = 1; | ||
318 | |||
319 | for (i = 0; i < loop_max; i++) { | ||
285 | u32 addr = regAddr[i]; | 320 | u32 addr = regAddr[i]; |
286 | u32 wrData, rdData; | 321 | u32 wrData, rdData; |
287 | 322 | ||
@@ -336,7 +371,13 @@ static void ath9k_hw_init_config(struct ath_hw *ah) | |||
336 | ah->config.ofdm_trig_high = 500; | 371 | ah->config.ofdm_trig_high = 500; |
337 | ah->config.cck_trig_high = 200; | 372 | ah->config.cck_trig_high = 200; |
338 | ah->config.cck_trig_low = 100; | 373 | ah->config.cck_trig_low = 100; |
339 | ah->config.enable_ani = 1; | 374 | |
375 | /* | ||
376 | * For now ANI is disabled for AR9003, it is still | ||
377 | * being tested. | ||
378 | */ | ||
379 | if (!AR_SREV_9300_20_OR_LATER(ah)) | ||
380 | ah->config.enable_ani = 1; | ||
340 | 381 | ||
341 | for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { | 382 | for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { |
342 | ah->config.spurchans[i][0] = AR_NO_SPUR; | 383 | ah->config.spurchans[i][0] = AR_NO_SPUR; |
@@ -351,6 +392,12 @@ static void ath9k_hw_init_config(struct ath_hw *ah) | |||
351 | ah->config.rx_intr_mitigation = true; | 392 | ah->config.rx_intr_mitigation = true; |
352 | 393 | ||
353 | /* | 394 | /* |
395 | * Tx IQ Calibration (ah->config.tx_iq_calibration) is only | ||
396 | * used by AR9003, but it is showing reliability issues. | ||
397 | * It will take a while to fix so this is currently disabled. | ||
398 | */ | ||
399 | |||
400 | /* | ||
354 | * We need this for PCI devices only (Cardbus, PCI, miniPCI) | 401 | * We need this for PCI devices only (Cardbus, PCI, miniPCI) |
355 | * _and_ if on non-uniprocessor systems (Multiprocessor/HT). | 402 | * _and_ if on non-uniprocessor systems (Multiprocessor/HT). |
356 | * This means we use it for all AR5416 devices, and the few | 403 | * This means we use it for all AR5416 devices, and the few |
@@ -369,7 +416,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah) | |||
369 | if (num_possible_cpus() > 1) | 416 | if (num_possible_cpus() > 1) |
370 | ah->config.serialize_regmode = SER_REG_MODE_AUTO; | 417 | ah->config.serialize_regmode = SER_REG_MODE_AUTO; |
371 | } | 418 | } |
372 | EXPORT_SYMBOL(ath9k_hw_init); | ||
373 | 419 | ||
374 | static void ath9k_hw_init_defaults(struct ath_hw *ah) | 420 | static void ath9k_hw_init_defaults(struct ath_hw *ah) |
375 | { | 421 | { |
@@ -383,8 +429,6 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah) | |||
383 | ah->hw_version.subvendorid = 0; | 429 | ah->hw_version.subvendorid = 0; |
384 | 430 | ||
385 | ah->ah_flags = 0; | 431 | ah->ah_flags = 0; |
386 | if (ah->hw_version.devid == AR5416_AR9100_DEVID) | ||
387 | ah->hw_version.macVersion = AR_SREV_VERSION_9100; | ||
388 | if (!AR_SREV_9100(ah)) | 432 | if (!AR_SREV_9100(ah)) |
389 | ah->ah_flags = AH_USE_EEPROM; | 433 | ah->ah_flags = AH_USE_EEPROM; |
390 | 434 | ||
@@ -397,44 +441,17 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah) | |||
397 | ah->power_mode = ATH9K_PM_UNDEFINED; | 441 | ah->power_mode = ATH9K_PM_UNDEFINED; |
398 | } | 442 | } |
399 | 443 | ||
400 | static int ath9k_hw_rf_claim(struct ath_hw *ah) | ||
401 | { | ||
402 | u32 val; | ||
403 | |||
404 | REG_WRITE(ah, AR_PHY(0), 0x00000007); | ||
405 | |||
406 | val = ath9k_hw_get_radiorev(ah); | ||
407 | switch (val & AR_RADIO_SREV_MAJOR) { | ||
408 | case 0: | ||
409 | val = AR_RAD5133_SREV_MAJOR; | ||
410 | break; | ||
411 | case AR_RAD5133_SREV_MAJOR: | ||
412 | case AR_RAD5122_SREV_MAJOR: | ||
413 | case AR_RAD2133_SREV_MAJOR: | ||
414 | case AR_RAD2122_SREV_MAJOR: | ||
415 | break; | ||
416 | default: | ||
417 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, | ||
418 | "Radio Chip Rev 0x%02X not supported\n", | ||
419 | val & AR_RADIO_SREV_MAJOR); | ||
420 | return -EOPNOTSUPP; | ||
421 | } | ||
422 | |||
423 | ah->hw_version.analog5GhzRev = val; | ||
424 | |||
425 | return 0; | ||
426 | } | ||
427 | |||
428 | static int ath9k_hw_init_macaddr(struct ath_hw *ah) | 444 | static int ath9k_hw_init_macaddr(struct ath_hw *ah) |
429 | { | 445 | { |
430 | struct ath_common *common = ath9k_hw_common(ah); | 446 | struct ath_common *common = ath9k_hw_common(ah); |
431 | u32 sum; | 447 | u32 sum; |
432 | int i; | 448 | int i; |
433 | u16 eeval; | 449 | u16 eeval; |
450 | u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW }; | ||
434 | 451 | ||
435 | sum = 0; | 452 | sum = 0; |
436 | for (i = 0; i < 3; i++) { | 453 | for (i = 0; i < 3; i++) { |
437 | eeval = ah->eep_ops->get_eeprom(ah, AR_EEPROM_MAC(i)); | 454 | eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]); |
438 | sum += eeval; | 455 | sum += eeval; |
439 | common->macaddr[2 * i] = eeval >> 8; | 456 | common->macaddr[2 * i] = eeval >> 8; |
440 | common->macaddr[2 * i + 1] = eeval & 0xff; | 457 | common->macaddr[2 * i + 1] = eeval & 0xff; |
@@ -445,54 +462,6 @@ static int ath9k_hw_init_macaddr(struct ath_hw *ah) | |||
445 | return 0; | 462 | return 0; |
446 | } | 463 | } |
447 | 464 | ||
448 | static void ath9k_hw_init_rxgain_ini(struct ath_hw *ah) | ||
449 | { | ||
450 | u32 rxgain_type; | ||
451 | |||
452 | if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= AR5416_EEP_MINOR_VER_17) { | ||
453 | rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE); | ||
454 | |||
455 | if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF) | ||
456 | INIT_INI_ARRAY(&ah->iniModesRxGain, | ||
457 | ar9280Modes_backoff_13db_rxgain_9280_2, | ||
458 | ARRAY_SIZE(ar9280Modes_backoff_13db_rxgain_9280_2), 6); | ||
459 | else if (rxgain_type == AR5416_EEP_RXGAIN_23DB_BACKOFF) | ||
460 | INIT_INI_ARRAY(&ah->iniModesRxGain, | ||
461 | ar9280Modes_backoff_23db_rxgain_9280_2, | ||
462 | ARRAY_SIZE(ar9280Modes_backoff_23db_rxgain_9280_2), 6); | ||
463 | else | ||
464 | INIT_INI_ARRAY(&ah->iniModesRxGain, | ||
465 | ar9280Modes_original_rxgain_9280_2, | ||
466 | ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6); | ||
467 | } else { | ||
468 | INIT_INI_ARRAY(&ah->iniModesRxGain, | ||
469 | ar9280Modes_original_rxgain_9280_2, | ||
470 | ARRAY_SIZE(ar9280Modes_original_rxgain_9280_2), 6); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | static void ath9k_hw_init_txgain_ini(struct ath_hw *ah) | ||
475 | { | ||
476 | u32 txgain_type; | ||
477 | |||
478 | if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= AR5416_EEP_MINOR_VER_19) { | ||
479 | txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); | ||
480 | |||
481 | if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) | ||
482 | INIT_INI_ARRAY(&ah->iniModesTxGain, | ||
483 | ar9280Modes_high_power_tx_gain_9280_2, | ||
484 | ARRAY_SIZE(ar9280Modes_high_power_tx_gain_9280_2), 6); | ||
485 | else | ||
486 | INIT_INI_ARRAY(&ah->iniModesTxGain, | ||
487 | ar9280Modes_original_tx_gain_9280_2, | ||
488 | ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6); | ||
489 | } else { | ||
490 | INIT_INI_ARRAY(&ah->iniModesTxGain, | ||
491 | ar9280Modes_original_tx_gain_9280_2, | ||
492 | ARRAY_SIZE(ar9280Modes_original_tx_gain_9280_2), 6); | ||
493 | } | ||
494 | } | ||
495 | |||
496 | static int ath9k_hw_post_init(struct ath_hw *ah) | 465 | static int ath9k_hw_post_init(struct ath_hw *ah) |
497 | { | 466 | { |
498 | int ecode; | 467 | int ecode; |
@@ -502,9 +471,11 @@ static int ath9k_hw_post_init(struct ath_hw *ah) | |||
502 | return -ENODEV; | 471 | return -ENODEV; |
503 | } | 472 | } |
504 | 473 | ||
505 | ecode = ath9k_hw_rf_claim(ah); | 474 | if (!AR_SREV_9300_20_OR_LATER(ah)) { |
506 | if (ecode != 0) | 475 | ecode = ar9002_hw_rf_claim(ah); |
507 | return ecode; | 476 | if (ecode != 0) |
477 | return ecode; | ||
478 | } | ||
508 | 479 | ||
509 | ecode = ath9k_hw_eeprom_init(ah); | 480 | ecode = ath9k_hw_eeprom_init(ah); |
510 | if (ecode != 0) | 481 | if (ecode != 0) |
@@ -515,14 +486,12 @@ static int ath9k_hw_post_init(struct ath_hw *ah) | |||
515 | ah->eep_ops->get_eeprom_ver(ah), | 486 | ah->eep_ops->get_eeprom_ver(ah), |
516 | ah->eep_ops->get_eeprom_rev(ah)); | 487 | ah->eep_ops->get_eeprom_rev(ah)); |
517 | 488 | ||
518 | if (!AR_SREV_9280_10_OR_LATER(ah)) { | 489 | ecode = ath9k_hw_rf_alloc_ext_banks(ah); |
519 | ecode = ath9k_hw_rf_alloc_ext_banks(ah); | 490 | if (ecode) { |
520 | if (ecode) { | 491 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
521 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, | 492 | "Failed allocating banks for " |
522 | "Failed allocating banks for " | 493 | "external radio\n"); |
523 | "external radio\n"); | 494 | return ecode; |
524 | return ecode; | ||
525 | } | ||
526 | } | 495 | } |
527 | 496 | ||
528 | if (!AR_SREV_9100(ah)) { | 497 | if (!AR_SREV_9100(ah)) { |
@@ -533,344 +502,22 @@ static int ath9k_hw_post_init(struct ath_hw *ah) | |||
533 | return 0; | 502 | return 0; |
534 | } | 503 | } |
535 | 504 | ||
536 | static bool ath9k_hw_devid_supported(u16 devid) | 505 | static void ath9k_hw_attach_ops(struct ath_hw *ah) |
537 | { | ||
538 | switch (devid) { | ||
539 | case AR5416_DEVID_PCI: | ||
540 | case AR5416_DEVID_PCIE: | ||
541 | case AR5416_AR9100_DEVID: | ||
542 | case AR9160_DEVID_PCI: | ||
543 | case AR9280_DEVID_PCI: | ||
544 | case AR9280_DEVID_PCIE: | ||
545 | case AR9285_DEVID_PCIE: | ||
546 | case AR5416_DEVID_AR9287_PCI: | ||
547 | case AR5416_DEVID_AR9287_PCIE: | ||
548 | case AR2427_DEVID_PCIE: | ||
549 | return true; | ||
550 | default: | ||
551 | break; | ||
552 | } | ||
553 | return false; | ||
554 | } | ||
555 | |||
556 | static bool ath9k_hw_macversion_supported(u32 macversion) | ||
557 | { | 506 | { |
558 | switch (macversion) { | 507 | if (AR_SREV_9300_20_OR_LATER(ah)) |
559 | case AR_SREV_VERSION_5416_PCI: | 508 | ar9003_hw_attach_ops(ah); |
560 | case AR_SREV_VERSION_5416_PCIE: | 509 | else |
561 | case AR_SREV_VERSION_9160: | 510 | ar9002_hw_attach_ops(ah); |
562 | case AR_SREV_VERSION_9100: | ||
563 | case AR_SREV_VERSION_9280: | ||
564 | case AR_SREV_VERSION_9285: | ||
565 | case AR_SREV_VERSION_9287: | ||
566 | case AR_SREV_VERSION_9271: | ||
567 | return true; | ||
568 | default: | ||
569 | break; | ||
570 | } | ||
571 | return false; | ||
572 | } | ||
573 | |||
574 | static void ath9k_hw_init_cal_settings(struct ath_hw *ah) | ||
575 | { | ||
576 | if (AR_SREV_9160_10_OR_LATER(ah)) { | ||
577 | if (AR_SREV_9280_10_OR_LATER(ah)) { | ||
578 | ah->iq_caldata.calData = &iq_cal_single_sample; | ||
579 | ah->adcgain_caldata.calData = | ||
580 | &adc_gain_cal_single_sample; | ||
581 | ah->adcdc_caldata.calData = | ||
582 | &adc_dc_cal_single_sample; | ||
583 | ah->adcdc_calinitdata.calData = | ||
584 | &adc_init_dc_cal; | ||
585 | } else { | ||
586 | ah->iq_caldata.calData = &iq_cal_multi_sample; | ||
587 | ah->adcgain_caldata.calData = | ||
588 | &adc_gain_cal_multi_sample; | ||
589 | ah->adcdc_caldata.calData = | ||
590 | &adc_dc_cal_multi_sample; | ||
591 | ah->adcdc_calinitdata.calData = | ||
592 | &adc_init_dc_cal; | ||
593 | } | ||
594 | ah->supp_cals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | static void ath9k_hw_init_mode_regs(struct ath_hw *ah) | ||
599 | { | ||
600 | if (AR_SREV_9271(ah)) { | ||
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); | ||
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); | ||
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); | ||
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); | ||
622 | return; | ||
623 | } | ||
624 | |||
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); | ||
644 | |||
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 | |||
656 | |||
657 | INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2, | ||
658 | ARRAY_SIZE(ar9285Modes_9285_1_2), 6); | ||
659 | INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2, | ||
660 | ARRAY_SIZE(ar9285Common_9285_1_2), 2); | ||
661 | |||
662 | if (ah->config.pcie_clock_req) { | ||
663 | INIT_INI_ARRAY(&ah->iniPcieSerdes, | ||
664 | ar9285PciePhy_clkreq_off_L1_9285_1_2, | ||
665 | ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285_1_2), 2); | ||
666 | } else { | ||
667 | INIT_INI_ARRAY(&ah->iniPcieSerdes, | ||
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)) { | ||
673 | INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285, | ||
674 | ARRAY_SIZE(ar9285Modes_9285), 6); | ||
675 | INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285, | ||
676 | ARRAY_SIZE(ar9285Common_9285), 2); | ||
677 | |||
678 | if (ah->config.pcie_clock_req) { | ||
679 | INIT_INI_ARRAY(&ah->iniPcieSerdes, | ||
680 | ar9285PciePhy_clkreq_off_L1_9285, | ||
681 | ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285), 2); | ||
682 | } else { | ||
683 | INIT_INI_ARRAY(&ah->iniPcieSerdes, | ||
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)) { | ||
688 | INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2, | ||
689 | ARRAY_SIZE(ar9280Modes_9280_2), 6); | ||
690 | INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2, | ||
691 | ARRAY_SIZE(ar9280Common_9280_2), 2); | ||
692 | |||
693 | if (ah->config.pcie_clock_req) { | ||
694 | INIT_INI_ARRAY(&ah->iniPcieSerdes, | ||
695 | ar9280PciePhy_clkreq_off_L1_9280, | ||
696 | ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280),2); | ||
697 | } else { | ||
698 | INIT_INI_ARRAY(&ah->iniPcieSerdes, | ||
699 | ar9280PciePhy_clkreq_always_on_L1_9280, | ||
700 | ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2); | ||
701 | } | ||
702 | INIT_INI_ARRAY(&ah->iniModesAdditional, | ||
703 | ar9280Modes_fast_clock_9280_2, | ||
704 | ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3); | ||
705 | } else if (AR_SREV_9280_10_OR_LATER(ah)) { | ||
706 | INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280, | ||
707 | ARRAY_SIZE(ar9280Modes_9280), 6); | ||
708 | INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280, | ||
709 | ARRAY_SIZE(ar9280Common_9280), 2); | ||
710 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { | ||
711 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9160, | ||
712 | ARRAY_SIZE(ar5416Modes_9160), 6); | ||
713 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160, | ||
714 | ARRAY_SIZE(ar5416Common_9160), 2); | ||
715 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9160, | ||
716 | ARRAY_SIZE(ar5416Bank0_9160), 2); | ||
717 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9160, | ||
718 | ARRAY_SIZE(ar5416BB_RfGain_9160), 3); | ||
719 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9160, | ||
720 | ARRAY_SIZE(ar5416Bank1_9160), 2); | ||
721 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9160, | ||
722 | ARRAY_SIZE(ar5416Bank2_9160), 2); | ||
723 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9160, | ||
724 | ARRAY_SIZE(ar5416Bank3_9160), 3); | ||
725 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9160, | ||
726 | ARRAY_SIZE(ar5416Bank6_9160), 3); | ||
727 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9160, | ||
728 | ARRAY_SIZE(ar5416Bank6TPC_9160), 3); | ||
729 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9160, | ||
730 | ARRAY_SIZE(ar5416Bank7_9160), 2); | ||
731 | if (AR_SREV_9160_11(ah)) { | ||
732 | INIT_INI_ARRAY(&ah->iniAddac, | ||
733 | ar5416Addac_91601_1, | ||
734 | ARRAY_SIZE(ar5416Addac_91601_1), 2); | ||
735 | } else { | ||
736 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160, | ||
737 | ARRAY_SIZE(ar5416Addac_9160), 2); | ||
738 | } | ||
739 | } else if (AR_SREV_9100_OR_LATER(ah)) { | ||
740 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes_9100, | ||
741 | ARRAY_SIZE(ar5416Modes_9100), 6); | ||
742 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100, | ||
743 | ARRAY_SIZE(ar5416Common_9100), 2); | ||
744 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9100, | ||
745 | ARRAY_SIZE(ar5416Bank0_9100), 2); | ||
746 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9100, | ||
747 | ARRAY_SIZE(ar5416BB_RfGain_9100), 3); | ||
748 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9100, | ||
749 | ARRAY_SIZE(ar5416Bank1_9100), 2); | ||
750 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9100, | ||
751 | ARRAY_SIZE(ar5416Bank2_9100), 2); | ||
752 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9100, | ||
753 | ARRAY_SIZE(ar5416Bank3_9100), 3); | ||
754 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100, | ||
755 | ARRAY_SIZE(ar5416Bank6_9100), 3); | ||
756 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100, | ||
757 | ARRAY_SIZE(ar5416Bank6TPC_9100), 3); | ||
758 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9100, | ||
759 | ARRAY_SIZE(ar5416Bank7_9100), 2); | ||
760 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100, | ||
761 | ARRAY_SIZE(ar5416Addac_9100), 2); | ||
762 | } else { | ||
763 | INIT_INI_ARRAY(&ah->iniModes, ar5416Modes, | ||
764 | ARRAY_SIZE(ar5416Modes), 6); | ||
765 | INIT_INI_ARRAY(&ah->iniCommon, ar5416Common, | ||
766 | ARRAY_SIZE(ar5416Common), 2); | ||
767 | INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0, | ||
768 | ARRAY_SIZE(ar5416Bank0), 2); | ||
769 | INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain, | ||
770 | ARRAY_SIZE(ar5416BB_RfGain), 3); | ||
771 | INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1, | ||
772 | ARRAY_SIZE(ar5416Bank1), 2); | ||
773 | INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2, | ||
774 | ARRAY_SIZE(ar5416Bank2), 2); | ||
775 | INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3, | ||
776 | ARRAY_SIZE(ar5416Bank3), 3); | ||
777 | INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6, | ||
778 | ARRAY_SIZE(ar5416Bank6), 3); | ||
779 | INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC, | ||
780 | ARRAY_SIZE(ar5416Bank6TPC), 3); | ||
781 | INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7, | ||
782 | ARRAY_SIZE(ar5416Bank7), 2); | ||
783 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, | ||
784 | ARRAY_SIZE(ar5416Addac), 2); | ||
785 | } | ||
786 | } | ||
787 | |||
788 | static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah) | ||
789 | { | ||
790 | if (AR_SREV_9287_11_OR_LATER(ah)) | ||
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 | |||
801 | if (AR_SREV_9287_11_OR_LATER(ah)) { | ||
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)) { | ||
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) { | ||
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 | } | ||
827 | } else { | ||
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 | } | ||
839 | } | ||
840 | } | ||
841 | } | ||
842 | |||
843 | static void ath9k_hw_init_eeprom_fix(struct ath_hw *ah) | ||
844 | { | ||
845 | struct base_eep_header *pBase = &(ah->eeprom.def.baseEepHeader); | ||
846 | struct ath_common *common = ath9k_hw_common(ah); | ||
847 | |||
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); | ||
852 | |||
853 | if (ah->need_an_top2_fixup) | ||
854 | ath_print(common, ATH_DBG_EEPROM, | ||
855 | "needs fixup for AR_AN_TOP2 register\n"); | ||
856 | } | 511 | } |
857 | 512 | ||
858 | int ath9k_hw_init(struct ath_hw *ah) | 513 | /* Called for all hardware families */ |
514 | static int __ath9k_hw_init(struct ath_hw *ah) | ||
859 | { | 515 | { |
860 | struct ath_common *common = ath9k_hw_common(ah); | 516 | struct ath_common *common = ath9k_hw_common(ah); |
861 | int r = 0; | 517 | int r = 0; |
862 | 518 | ||
863 | if (common->bus_ops->ath_bus_type != ATH_USB) { | 519 | if (ah->hw_version.devid == AR5416_AR9100_DEVID) |
864 | if (!ath9k_hw_devid_supported(ah->hw_version.devid)) { | 520 | ah->hw_version.macVersion = AR_SREV_VERSION_9100; |
865 | ath_print(common, ATH_DBG_FATAL, | ||
866 | "Unsupported device ID: 0x%0x\n", | ||
867 | ah->hw_version.devid); | ||
868 | return -EOPNOTSUPP; | ||
869 | } | ||
870 | } | ||
871 | |||
872 | ath9k_hw_init_defaults(ah); | ||
873 | ath9k_hw_init_config(ah); | ||
874 | 521 | ||
875 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { | 522 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { |
876 | ath_print(common, ATH_DBG_FATAL, | 523 | ath_print(common, ATH_DBG_FATAL, |
@@ -878,6 +525,11 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
878 | return -EIO; | 525 | return -EIO; |
879 | } | 526 | } |
880 | 527 | ||
528 | ath9k_hw_init_defaults(ah); | ||
529 | ath9k_hw_init_config(ah); | ||
530 | |||
531 | ath9k_hw_attach_ops(ah); | ||
532 | |||
881 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) { | 533 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) { |
882 | ath_print(common, ATH_DBG_FATAL, "Couldn't wakeup chip\n"); | 534 | ath_print(common, ATH_DBG_FATAL, "Couldn't wakeup chip\n"); |
883 | return -EIO; | 535 | return -EIO; |
@@ -902,7 +554,7 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
902 | else | 554 | else |
903 | ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD; | 555 | ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD; |
904 | 556 | ||
905 | if (!ath9k_hw_macversion_supported(ah->hw_version.macVersion)) { | 557 | if (!ath9k_hw_macversion_supported(ah)) { |
906 | ath_print(common, ATH_DBG_FATAL, | 558 | ath_print(common, ATH_DBG_FATAL, |
907 | "Mac Chip Rev 0x%02x.%x is not supported by " | 559 | "Mac Chip Rev 0x%02x.%x is not supported by " |
908 | "this driver\n", ah->hw_version.macVersion, | 560 | "this driver\n", ah->hw_version.macVersion, |
@@ -910,28 +562,15 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
910 | return -EOPNOTSUPP; | 562 | return -EOPNOTSUPP; |
911 | } | 563 | } |
912 | 564 | ||
913 | if (AR_SREV_9100(ah)) { | 565 | if (AR_SREV_9271(ah) || AR_SREV_9100(ah)) |
914 | ah->iq_caldata.calData = &iq_cal_multi_sample; | ||
915 | ah->supp_cals = IQ_MISMATCH_CAL; | ||
916 | ah->is_pciexpress = false; | ||
917 | } | ||
918 | |||
919 | if (AR_SREV_9271(ah)) | ||
920 | ah->is_pciexpress = false; | 566 | ah->is_pciexpress = false; |
921 | 567 | ||
922 | ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID); | 568 | ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID); |
923 | |||
924 | ath9k_hw_init_cal_settings(ah); | 569 | ath9k_hw_init_cal_settings(ah); |
925 | 570 | ||
926 | ah->ani_function = ATH9K_ANI_ALL; | 571 | ah->ani_function = ATH9K_ANI_ALL; |
927 | if (AR_SREV_9280_10_OR_LATER(ah)) { | 572 | if (AR_SREV_9280_10_OR_LATER(ah) && !AR_SREV_9300_20_OR_LATER(ah)) |
928 | ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL; | 573 | ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL; |
929 | ah->ath9k_hw_rf_set_freq = &ath9k_hw_ar9280_set_channel; | ||
930 | ah->ath9k_hw_spur_mitigate_freq = &ath9k_hw_9280_spur_mitigate; | ||
931 | } else { | ||
932 | ah->ath9k_hw_rf_set_freq = &ath9k_hw_set_channel; | ||
933 | ah->ath9k_hw_spur_mitigate_freq = &ath9k_hw_spur_mitigate; | ||
934 | } | ||
935 | 574 | ||
936 | ath9k_hw_init_mode_regs(ah); | 575 | ath9k_hw_init_mode_regs(ah); |
937 | 576 | ||
@@ -940,15 +579,8 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
940 | else | 579 | else |
941 | ath9k_hw_disablepcie(ah); | 580 | ath9k_hw_disablepcie(ah); |
942 | 581 | ||
943 | /* Support for Japan ch.14 (2484) spread */ | 582 | if (!AR_SREV_9300_20_OR_LATER(ah)) |
944 | if (AR_SREV_9287_11_OR_LATER(ah)) { | 583 | ar9002_hw_cck_chan14_spread(ah); |
945 | INIT_INI_ARRAY(&ah->iniCckfirNormal, | ||
946 | ar9287Common_normal_cck_fir_coeff_92871_1, | ||
947 | ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_92871_1), 2); | ||
948 | INIT_INI_ARRAY(&ah->iniCckfirJapan2484, | ||
949 | ar9287Common_japan_2484_cck_fir_coeff_92871_1, | ||
950 | ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_92871_1), 2); | ||
951 | } | ||
952 | 584 | ||
953 | r = ath9k_hw_post_init(ah); | 585 | r = ath9k_hw_post_init(ah); |
954 | if (r) | 586 | if (r) |
@@ -959,8 +591,6 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
959 | if (r) | 591 | if (r) |
960 | return r; | 592 | return r; |
961 | 593 | ||
962 | ath9k_hw_init_eeprom_fix(ah); | ||
963 | |||
964 | r = ath9k_hw_init_macaddr(ah); | 594 | r = ath9k_hw_init_macaddr(ah); |
965 | if (r) { | 595 | if (r) { |
966 | ath_print(common, ATH_DBG_FATAL, | 596 | ath_print(common, ATH_DBG_FATAL, |
@@ -973,6 +603,9 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
973 | else | 603 | else |
974 | ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); | 604 | ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); |
975 | 605 | ||
606 | if (AR_SREV_9300_20_OR_LATER(ah)) | ||
607 | ar9003_hw_set_nf_limits(ah); | ||
608 | |||
976 | ath9k_init_nfcal_hist_buffer(ah); | 609 | ath9k_init_nfcal_hist_buffer(ah); |
977 | 610 | ||
978 | common->state = ATH_HW_INITIALIZED; | 611 | common->state = ATH_HW_INITIALIZED; |
@@ -980,24 +613,50 @@ int ath9k_hw_init(struct ath_hw *ah) | |||
980 | return 0; | 613 | return 0; |
981 | } | 614 | } |
982 | 615 | ||
983 | static void ath9k_hw_init_bb(struct ath_hw *ah, | 616 | int ath9k_hw_init(struct ath_hw *ah) |
984 | struct ath9k_channel *chan) | ||
985 | { | 617 | { |
986 | u32 synthDelay; | 618 | int ret; |
619 | struct ath_common *common = ath9k_hw_common(ah); | ||
987 | 620 | ||
988 | synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY; | 621 | /* These are all the AR5008/AR9001/AR9002 hardware family of chipsets */ |
989 | if (IS_CHAN_B(chan)) | 622 | switch (ah->hw_version.devid) { |
990 | synthDelay = (4 * synthDelay) / 22; | 623 | case AR5416_DEVID_PCI: |
991 | else | 624 | case AR5416_DEVID_PCIE: |
992 | synthDelay /= 10; | 625 | case AR5416_AR9100_DEVID: |
626 | case AR9160_DEVID_PCI: | ||
627 | case AR9280_DEVID_PCI: | ||
628 | case AR9280_DEVID_PCIE: | ||
629 | case AR9285_DEVID_PCIE: | ||
630 | case AR9287_DEVID_PCI: | ||
631 | case AR9287_DEVID_PCIE: | ||
632 | case AR2427_DEVID_PCIE: | ||
633 | case AR9300_DEVID_PCIE: | ||
634 | break; | ||
635 | default: | ||
636 | if (common->bus_ops->ath_bus_type == ATH_USB) | ||
637 | break; | ||
638 | ath_print(common, ATH_DBG_FATAL, | ||
639 | "Hardware device ID 0x%04x not supported\n", | ||
640 | ah->hw_version.devid); | ||
641 | return -EOPNOTSUPP; | ||
642 | } | ||
993 | 643 | ||
994 | REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN); | 644 | ret = __ath9k_hw_init(ah); |
645 | if (ret) { | ||
646 | ath_print(common, ATH_DBG_FATAL, | ||
647 | "Unable to initialize hardware; " | ||
648 | "initialization status: %d\n", ret); | ||
649 | return ret; | ||
650 | } | ||
995 | 651 | ||
996 | udelay(synthDelay + BASE_ACTIVATE_DELAY); | 652 | return 0; |
997 | } | 653 | } |
654 | EXPORT_SYMBOL(ath9k_hw_init); | ||
998 | 655 | ||
999 | static void ath9k_hw_init_qos(struct ath_hw *ah) | 656 | static void ath9k_hw_init_qos(struct ath_hw *ah) |
1000 | { | 657 | { |
658 | ENABLE_REGWRITE_BUFFER(ah); | ||
659 | |||
1001 | REG_WRITE(ah, AR_MIC_QOS_CONTROL, 0x100aa); | 660 | REG_WRITE(ah, AR_MIC_QOS_CONTROL, 0x100aa); |
1002 | REG_WRITE(ah, AR_MIC_QOS_SELECT, 0x3210); | 661 | REG_WRITE(ah, AR_MIC_QOS_SELECT, 0x3210); |
1003 | 662 | ||
@@ -1011,69 +670,16 @@ static void ath9k_hw_init_qos(struct ath_hw *ah) | |||
1011 | REG_WRITE(ah, AR_TXOP_4_7, 0xFFFFFFFF); | 670 | REG_WRITE(ah, AR_TXOP_4_7, 0xFFFFFFFF); |
1012 | REG_WRITE(ah, AR_TXOP_8_11, 0xFFFFFFFF); | 671 | REG_WRITE(ah, AR_TXOP_8_11, 0xFFFFFFFF); |
1013 | REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF); | 672 | REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF); |
673 | |||
674 | REGWRITE_BUFFER_FLUSH(ah); | ||
675 | DISABLE_REGWRITE_BUFFER(ah); | ||
1014 | } | 676 | } |
1015 | 677 | ||
1016 | static void ath9k_hw_init_pll(struct ath_hw *ah, | 678 | static void ath9k_hw_init_pll(struct ath_hw *ah, |
1017 | struct ath9k_channel *chan) | 679 | struct ath9k_channel *chan) |
1018 | { | 680 | { |
1019 | u32 pll; | 681 | u32 pll = ath9k_hw_compute_pll_control(ah, chan); |
1020 | |||
1021 | if (AR_SREV_9100(ah)) { | ||
1022 | if (chan && IS_CHAN_5GHZ(chan)) | ||
1023 | pll = 0x1450; | ||
1024 | else | ||
1025 | pll = 0x1458; | ||
1026 | } else { | ||
1027 | if (AR_SREV_9280_10_OR_LATER(ah)) { | ||
1028 | pll = SM(0x5, AR_RTC_9160_PLL_REFDIV); | ||
1029 | |||
1030 | if (chan && IS_CHAN_HALF_RATE(chan)) | ||
1031 | pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL); | ||
1032 | else if (chan && IS_CHAN_QUARTER_RATE(chan)) | ||
1033 | pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL); | ||
1034 | |||
1035 | if (chan && IS_CHAN_5GHZ(chan)) { | ||
1036 | pll |= SM(0x28, AR_RTC_9160_PLL_DIV); | ||
1037 | |||
1038 | 682 | ||
1039 | if (AR_SREV_9280_20(ah)) { | ||
1040 | if (((chan->channel % 20) == 0) | ||
1041 | || ((chan->channel % 10) == 0)) | ||
1042 | pll = 0x2850; | ||
1043 | else | ||
1044 | pll = 0x142c; | ||
1045 | } | ||
1046 | } else { | ||
1047 | pll |= SM(0x2c, AR_RTC_9160_PLL_DIV); | ||
1048 | } | ||
1049 | |||
1050 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { | ||
1051 | |||
1052 | pll = SM(0x5, AR_RTC_9160_PLL_REFDIV); | ||
1053 | |||
1054 | if (chan && IS_CHAN_HALF_RATE(chan)) | ||
1055 | pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL); | ||
1056 | else if (chan && IS_CHAN_QUARTER_RATE(chan)) | ||
1057 | pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL); | ||
1058 | |||
1059 | if (chan && IS_CHAN_5GHZ(chan)) | ||
1060 | pll |= SM(0x50, AR_RTC_9160_PLL_DIV); | ||
1061 | else | ||
1062 | pll |= SM(0x58, AR_RTC_9160_PLL_DIV); | ||
1063 | } else { | ||
1064 | pll = AR_RTC_PLL_REFDIV_5 | AR_RTC_PLL_DIV2; | ||
1065 | |||
1066 | if (chan && IS_CHAN_HALF_RATE(chan)) | ||
1067 | pll |= SM(0x1, AR_RTC_PLL_CLKSEL); | ||
1068 | else if (chan && IS_CHAN_QUARTER_RATE(chan)) | ||
1069 | pll |= SM(0x2, AR_RTC_PLL_CLKSEL); | ||
1070 | |||
1071 | if (chan && IS_CHAN_5GHZ(chan)) | ||
1072 | pll |= SM(0xa, AR_RTC_PLL_DIV); | ||
1073 | else | ||
1074 | pll |= SM(0xb, AR_RTC_PLL_DIV); | ||
1075 | } | ||
1076 | } | ||
1077 | REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll); | 683 | REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll); |
1078 | 684 | ||
1079 | /* Switch the core clock for ar9271 to 117Mhz */ | 685 | /* Switch the core clock for ar9271 to 117Mhz */ |
@@ -1087,43 +693,6 @@ static void ath9k_hw_init_pll(struct ath_hw *ah, | |||
1087 | REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK); | 693 | REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK); |
1088 | } | 694 | } |
1089 | 695 | ||
1090 | static void ath9k_hw_init_chain_masks(struct ath_hw *ah) | ||
1091 | { | ||
1092 | int rx_chainmask, tx_chainmask; | ||
1093 | |||
1094 | rx_chainmask = ah->rxchainmask; | ||
1095 | tx_chainmask = ah->txchainmask; | ||
1096 | |||
1097 | switch (rx_chainmask) { | ||
1098 | case 0x5: | ||
1099 | REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, | ||
1100 | AR_PHY_SWAP_ALT_CHAIN); | ||
1101 | case 0x3: | ||
1102 | if (ah->hw_version.macVersion == AR_SREV_REVISION_5416_10) { | ||
1103 | REG_WRITE(ah, AR_PHY_RX_CHAINMASK, 0x7); | ||
1104 | REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, 0x7); | ||
1105 | break; | ||
1106 | } | ||
1107 | case 0x1: | ||
1108 | case 0x2: | ||
1109 | case 0x7: | ||
1110 | REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx_chainmask); | ||
1111 | REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx_chainmask); | ||
1112 | break; | ||
1113 | default: | ||
1114 | break; | ||
1115 | } | ||
1116 | |||
1117 | REG_WRITE(ah, AR_SELFGEN_MASK, tx_chainmask); | ||
1118 | if (tx_chainmask == 0x5) { | ||
1119 | REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, | ||
1120 | AR_PHY_SWAP_ALT_CHAIN); | ||
1121 | } | ||
1122 | if (AR_SREV_9100(ah)) | ||
1123 | REG_WRITE(ah, AR_PHY_ANALOG_SWAP, | ||
1124 | REG_READ(ah, AR_PHY_ANALOG_SWAP) | 0x00000001); | ||
1125 | } | ||
1126 | |||
1127 | static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, | 696 | static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, |
1128 | enum nl80211_iftype opmode) | 697 | enum nl80211_iftype opmode) |
1129 | { | 698 | { |
@@ -1133,16 +702,30 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, | |||
1133 | AR_IMR_RXORN | | 702 | AR_IMR_RXORN | |
1134 | AR_IMR_BCNMISC; | 703 | AR_IMR_BCNMISC; |
1135 | 704 | ||
1136 | if (ah->config.rx_intr_mitigation) | 705 | if (AR_SREV_9300_20_OR_LATER(ah)) { |
1137 | imr_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR; | 706 | imr_reg |= AR_IMR_RXOK_HP; |
1138 | else | 707 | if (ah->config.rx_intr_mitigation) |
1139 | imr_reg |= AR_IMR_RXOK; | 708 | imr_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR; |
709 | else | ||
710 | imr_reg |= AR_IMR_RXOK_LP; | ||
1140 | 711 | ||
1141 | imr_reg |= AR_IMR_TXOK; | 712 | } else { |
713 | if (ah->config.rx_intr_mitigation) | ||
714 | imr_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR; | ||
715 | else | ||
716 | imr_reg |= AR_IMR_RXOK; | ||
717 | } | ||
718 | |||
719 | if (ah->config.tx_intr_mitigation) | ||
720 | imr_reg |= AR_IMR_TXINTM | AR_IMR_TXMINTR; | ||
721 | else | ||
722 | imr_reg |= AR_IMR_TXOK; | ||
1142 | 723 | ||
1143 | if (opmode == NL80211_IFTYPE_AP) | 724 | if (opmode == NL80211_IFTYPE_AP) |
1144 | imr_reg |= AR_IMR_MIB; | 725 | imr_reg |= AR_IMR_MIB; |
1145 | 726 | ||
727 | ENABLE_REGWRITE_BUFFER(ah); | ||
728 | |||
1146 | REG_WRITE(ah, AR_IMR, imr_reg); | 729 | REG_WRITE(ah, AR_IMR, imr_reg); |
1147 | ah->imrs2_reg |= AR_IMR_S2_GTT; | 730 | ah->imrs2_reg |= AR_IMR_S2_GTT; |
1148 | REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg); | 731 | REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg); |
@@ -1152,6 +735,16 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, | |||
1152 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, AR_INTR_SYNC_DEFAULT); | 735 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, AR_INTR_SYNC_DEFAULT); |
1153 | REG_WRITE(ah, AR_INTR_SYNC_MASK, 0); | 736 | REG_WRITE(ah, AR_INTR_SYNC_MASK, 0); |
1154 | } | 737 | } |
738 | |||
739 | REGWRITE_BUFFER_FLUSH(ah); | ||
740 | DISABLE_REGWRITE_BUFFER(ah); | ||
741 | |||
742 | if (AR_SREV_9300_20_OR_LATER(ah)) { | ||
743 | REG_WRITE(ah, AR_INTR_PRIO_ASYNC_ENABLE, 0); | ||
744 | REG_WRITE(ah, AR_INTR_PRIO_ASYNC_MASK, 0); | ||
745 | REG_WRITE(ah, AR_INTR_PRIO_SYNC_ENABLE, 0); | ||
746 | REG_WRITE(ah, AR_INTR_PRIO_SYNC_MASK, 0); | ||
747 | } | ||
1155 | } | 748 | } |
1156 | 749 | ||
1157 | static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us) | 750 | static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us) |
@@ -1237,14 +830,10 @@ void ath9k_hw_deinit(struct ath_hw *ah) | |||
1237 | if (common->state < ATH_HW_INITIALIZED) | 830 | if (common->state < ATH_HW_INITIALIZED) |
1238 | goto free_hw; | 831 | goto free_hw; |
1239 | 832 | ||
1240 | if (!AR_SREV_9100(ah)) | ||
1241 | ath9k_hw_ani_disable(ah); | ||
1242 | |||
1243 | ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP); | 833 | ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP); |
1244 | 834 | ||
1245 | free_hw: | 835 | free_hw: |
1246 | if (!AR_SREV_9280_10_OR_LATER(ah)) | 836 | ath9k_hw_rf_free_ext_banks(ah); |
1247 | ath9k_hw_rf_free_ext_banks(ah); | ||
1248 | } | 837 | } |
1249 | EXPORT_SYMBOL(ath9k_hw_deinit); | 838 | EXPORT_SYMBOL(ath9k_hw_deinit); |
1250 | 839 | ||
@@ -1252,73 +841,7 @@ EXPORT_SYMBOL(ath9k_hw_deinit); | |||
1252 | /* INI */ | 841 | /* INI */ |
1253 | /*******/ | 842 | /*******/ |
1254 | 843 | ||
1255 | static void ath9k_hw_override_ini(struct ath_hw *ah, | 844 | u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan) |
1256 | struct ath9k_channel *chan) | ||
1257 | { | ||
1258 | u32 val; | ||
1259 | |||
1260 | /* | ||
1261 | * Set the RX_ABORT and RX_DIS and clear if off only after | ||
1262 | * RXE is set for MAC. This prevents frames with corrupted | ||
1263 | * descriptor status. | ||
1264 | */ | ||
1265 | REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); | ||
1266 | |||
1267 | if (AR_SREV_9280_10_OR_LATER(ah)) { | ||
1268 | val = REG_READ(ah, AR_PCU_MISC_MODE2); | ||
1269 | |||
1270 | if (!AR_SREV_9271(ah)) | ||
1271 | val &= ~AR_PCU_MISC_MODE2_HWWAR1; | ||
1272 | |||
1273 | if (AR_SREV_9287_10_OR_LATER(ah)) | ||
1274 | val = val & (~AR_PCU_MISC_MODE2_HWWAR2); | ||
1275 | |||
1276 | REG_WRITE(ah, AR_PCU_MISC_MODE2, val); | ||
1277 | } | ||
1278 | |||
1279 | if (!AR_SREV_5416_20_OR_LATER(ah) || | ||
1280 | AR_SREV_9280_10_OR_LATER(ah)) | ||
1281 | return; | ||
1282 | /* | ||
1283 | * Disable BB clock gating | ||
1284 | * Necessary to avoid issues on AR5416 2.0 | ||
1285 | */ | ||
1286 | REG_WRITE(ah, 0x9800 + (651 << 2), 0x11); | ||
1287 | |||
1288 | /* | ||
1289 | * Disable RIFS search on some chips to avoid baseband | ||
1290 | * hang issues. | ||
1291 | */ | ||
1292 | if (AR_SREV_9100(ah) || AR_SREV_9160(ah)) { | ||
1293 | val = REG_READ(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS); | ||
1294 | val &= ~AR_PHY_RIFS_INIT_DELAY; | ||
1295 | REG_WRITE(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS, val); | ||
1296 | } | ||
1297 | } | ||
1298 | |||
1299 | static void ath9k_olc_init(struct ath_hw *ah) | ||
1300 | { | ||
1301 | u32 i; | ||
1302 | |||
1303 | if (OLC_FOR_AR9287_10_LATER) { | ||
1304 | REG_SET_BIT(ah, AR_PHY_TX_PWRCTRL9, | ||
1305 | AR_PHY_TX_PWRCTRL9_RES_DC_REMOVAL); | ||
1306 | ath9k_hw_analog_shift_rmw(ah, AR9287_AN_TXPC0, | ||
1307 | AR9287_AN_TXPC0_TXPCMODE, | ||
1308 | AR9287_AN_TXPC0_TXPCMODE_S, | ||
1309 | AR9287_AN_TXPC0_TXPCMODE_TEMPSENSE); | ||
1310 | udelay(100); | ||
1311 | } else { | ||
1312 | for (i = 0; i < AR9280_TX_GAIN_TABLE_SIZE; i++) | ||
1313 | ah->originalGain[i] = | ||
1314 | MS(REG_READ(ah, AR_PHY_TX_GAIN_TBL1 + i * 4), | ||
1315 | AR_PHY_TX_GAIN); | ||
1316 | ah->PDADCdelta = 0; | ||
1317 | } | ||
1318 | } | ||
1319 | |||
1320 | static u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, | ||
1321 | struct ath9k_channel *chan) | ||
1322 | { | 845 | { |
1323 | u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band); | 846 | u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band); |
1324 | 847 | ||
@@ -1332,193 +855,24 @@ static u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, | |||
1332 | return ctl; | 855 | return ctl; |
1333 | } | 856 | } |
1334 | 857 | ||
1335 | static int ath9k_hw_process_ini(struct ath_hw *ah, | ||
1336 | struct ath9k_channel *chan) | ||
1337 | { | ||
1338 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); | ||
1339 | int i, regWrites = 0; | ||
1340 | struct ieee80211_channel *channel = chan->chan; | ||
1341 | u32 modesIndex, freqIndex; | ||
1342 | |||
1343 | switch (chan->chanmode) { | ||
1344 | case CHANNEL_A: | ||
1345 | case CHANNEL_A_HT20: | ||
1346 | modesIndex = 1; | ||
1347 | freqIndex = 1; | ||
1348 | break; | ||
1349 | case CHANNEL_A_HT40PLUS: | ||
1350 | case CHANNEL_A_HT40MINUS: | ||
1351 | modesIndex = 2; | ||
1352 | freqIndex = 1; | ||
1353 | break; | ||
1354 | case CHANNEL_G: | ||
1355 | case CHANNEL_G_HT20: | ||
1356 | case CHANNEL_B: | ||
1357 | modesIndex = 4; | ||
1358 | freqIndex = 2; | ||
1359 | break; | ||
1360 | case CHANNEL_G_HT40PLUS: | ||
1361 | case CHANNEL_G_HT40MINUS: | ||
1362 | modesIndex = 3; | ||
1363 | freqIndex = 2; | ||
1364 | break; | ||
1365 | |||
1366 | default: | ||
1367 | return -EINVAL; | ||
1368 | } | ||
1369 | |||
1370 | /* Set correct baseband to analog shift setting to access analog chips */ | ||
1371 | REG_WRITE(ah, AR_PHY(0), 0x00000007); | ||
1372 | |||
1373 | /* Write ADDAC shifts */ | ||
1374 | REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO); | ||
1375 | ah->eep_ops->set_addac(ah, chan); | ||
1376 | |||
1377 | if (AR_SREV_5416_22_OR_LATER(ah)) { | ||
1378 | REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites); | ||
1379 | } else { | ||
1380 | struct ar5416IniArray temp; | ||
1381 | u32 addacSize = | ||
1382 | sizeof(u32) * ah->iniAddac.ia_rows * | ||
1383 | ah->iniAddac.ia_columns; | ||
1384 | |||
1385 | /* For AR5416 2.0/2.1 */ | ||
1386 | memcpy(ah->addac5416_21, | ||
1387 | ah->iniAddac.ia_array, addacSize); | ||
1388 | |||
1389 | /* override CLKDRV value at [row, column] = [31, 1] */ | ||
1390 | (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0; | ||
1391 | |||
1392 | temp.ia_array = ah->addac5416_21; | ||
1393 | temp.ia_columns = ah->iniAddac.ia_columns; | ||
1394 | temp.ia_rows = ah->iniAddac.ia_rows; | ||
1395 | REG_WRITE_ARRAY(&temp, 1, regWrites); | ||
1396 | } | ||
1397 | |||
1398 | REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC); | ||
1399 | |||
1400 | for (i = 0; i < ah->iniModes.ia_rows; i++) { | ||
1401 | u32 reg = INI_RA(&ah->iniModes, i, 0); | ||
1402 | u32 val = INI_RA(&ah->iniModes, i, modesIndex); | ||
1403 | |||
1404 | if (reg == AR_AN_TOP2 && ah->need_an_top2_fixup) | ||
1405 | val &= ~AR_AN_TOP2_PWDCLKIND; | ||
1406 | |||
1407 | REG_WRITE(ah, reg, val); | ||
1408 | |||
1409 | if (reg >= 0x7800 && reg < 0x78a0 | ||
1410 | && ah->config.analog_shiftreg) { | ||
1411 | udelay(100); | ||
1412 | } | ||
1413 | |||
1414 | DO_DELAY(regWrites); | ||
1415 | } | ||
1416 | |||
1417 | if (AR_SREV_9280(ah) || AR_SREV_9287_10_OR_LATER(ah)) | ||
1418 | REG_WRITE_ARRAY(&ah->iniModesRxGain, modesIndex, regWrites); | ||
1419 | |||
1420 | if (AR_SREV_9280(ah) || AR_SREV_9285_12_OR_LATER(ah) || | ||
1421 | AR_SREV_9287_10_OR_LATER(ah)) | ||
1422 | REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); | ||
1423 | |||
1424 | if (AR_SREV_9271_10(ah)) | ||
1425 | REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only, | ||
1426 | modesIndex, regWrites); | ||
1427 | |||
1428 | /* Write common array parameters */ | ||
1429 | for (i = 0; i < ah->iniCommon.ia_rows; i++) { | ||
1430 | u32 reg = INI_RA(&ah->iniCommon, i, 0); | ||
1431 | u32 val = INI_RA(&ah->iniCommon, i, 1); | ||
1432 | |||
1433 | REG_WRITE(ah, reg, val); | ||
1434 | |||
1435 | if (reg >= 0x7800 && reg < 0x78a0 | ||
1436 | && ah->config.analog_shiftreg) { | ||
1437 | udelay(100); | ||
1438 | } | ||
1439 | |||
1440 | DO_DELAY(regWrites); | ||
1441 | } | ||
1442 | |||
1443 | if (AR_SREV_9271(ah)) { | ||
1444 | if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1) | ||
1445 | REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271, | ||
1446 | modesIndex, regWrites); | ||
1447 | else | ||
1448 | REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271, | ||
1449 | modesIndex, regWrites); | ||
1450 | } | ||
1451 | |||
1452 | ath9k_hw_write_regs(ah, freqIndex, regWrites); | ||
1453 | |||
1454 | if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) { | ||
1455 | REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, | ||
1456 | regWrites); | ||
1457 | } | ||
1458 | |||
1459 | ath9k_hw_override_ini(ah, chan); | ||
1460 | ath9k_hw_set_regs(ah, chan); | ||
1461 | ath9k_hw_init_chain_masks(ah); | ||
1462 | |||
1463 | if (OLC_FOR_AR9280_20_LATER) | ||
1464 | ath9k_olc_init(ah); | ||
1465 | |||
1466 | /* Set TX power */ | ||
1467 | ah->eep_ops->set_txpower(ah, chan, | ||
1468 | ath9k_regd_get_ctl(regulatory, chan), | ||
1469 | channel->max_antenna_gain * 2, | ||
1470 | channel->max_power * 2, | ||
1471 | min((u32) MAX_RATE_POWER, | ||
1472 | (u32) regulatory->power_limit)); | ||
1473 | |||
1474 | /* Write analog registers */ | ||
1475 | if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { | ||
1476 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, | ||
1477 | "ar5416SetRfRegs failed\n"); | ||
1478 | return -EIO; | ||
1479 | } | ||
1480 | |||
1481 | return 0; | ||
1482 | } | ||
1483 | |||
1484 | /****************************************/ | 858 | /****************************************/ |
1485 | /* Reset and Channel Switching Routines */ | 859 | /* Reset and Channel Switching Routines */ |
1486 | /****************************************/ | 860 | /****************************************/ |
1487 | 861 | ||
1488 | static void ath9k_hw_set_rfmode(struct ath_hw *ah, struct ath9k_channel *chan) | ||
1489 | { | ||
1490 | u32 rfMode = 0; | ||
1491 | |||
1492 | if (chan == NULL) | ||
1493 | return; | ||
1494 | |||
1495 | rfMode |= (IS_CHAN_B(chan) || IS_CHAN_G(chan)) | ||
1496 | ? AR_PHY_MODE_DYNAMIC : AR_PHY_MODE_OFDM; | ||
1497 | |||
1498 | if (!AR_SREV_9280_10_OR_LATER(ah)) | ||
1499 | rfMode |= (IS_CHAN_5GHZ(chan)) ? | ||
1500 | AR_PHY_MODE_RF5GHZ : AR_PHY_MODE_RF2GHZ; | ||
1501 | |||
1502 | if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) | ||
1503 | rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE); | ||
1504 | |||
1505 | REG_WRITE(ah, AR_PHY_MODE, rfMode); | ||
1506 | } | ||
1507 | |||
1508 | static void ath9k_hw_mark_phy_inactive(struct ath_hw *ah) | ||
1509 | { | ||
1510 | REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS); | ||
1511 | } | ||
1512 | |||
1513 | static inline void ath9k_hw_set_dma(struct ath_hw *ah) | 862 | static inline void ath9k_hw_set_dma(struct ath_hw *ah) |
1514 | { | 863 | { |
864 | struct ath_common *common = ath9k_hw_common(ah); | ||
1515 | u32 regval; | 865 | u32 regval; |
1516 | 866 | ||
867 | ENABLE_REGWRITE_BUFFER(ah); | ||
868 | |||
1517 | /* | 869 | /* |
1518 | * set AHB_MODE not to do cacheline prefetches | 870 | * set AHB_MODE not to do cacheline prefetches |
1519 | */ | 871 | */ |
1520 | regval = REG_READ(ah, AR_AHB_MODE); | 872 | if (!AR_SREV_9300_20_OR_LATER(ah)) { |
1521 | REG_WRITE(ah, AR_AHB_MODE, regval | AR_AHB_PREFETCH_RD_EN); | 873 | regval = REG_READ(ah, AR_AHB_MODE); |
874 | REG_WRITE(ah, AR_AHB_MODE, regval | AR_AHB_PREFETCH_RD_EN); | ||
875 | } | ||
1522 | 876 | ||
1523 | /* | 877 | /* |
1524 | * let mac dma reads be in 128 byte chunks | 878 | * let mac dma reads be in 128 byte chunks |
@@ -1526,12 +880,18 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah) | |||
1526 | regval = REG_READ(ah, AR_TXCFG) & ~AR_TXCFG_DMASZ_MASK; | 880 | regval = REG_READ(ah, AR_TXCFG) & ~AR_TXCFG_DMASZ_MASK; |
1527 | REG_WRITE(ah, AR_TXCFG, regval | AR_TXCFG_DMASZ_128B); | 881 | REG_WRITE(ah, AR_TXCFG, regval | AR_TXCFG_DMASZ_128B); |
1528 | 882 | ||
883 | REGWRITE_BUFFER_FLUSH(ah); | ||
884 | DISABLE_REGWRITE_BUFFER(ah); | ||
885 | |||
1529 | /* | 886 | /* |
1530 | * Restore TX Trigger Level to its pre-reset value. | 887 | * Restore TX Trigger Level to its pre-reset value. |
1531 | * The initial value depends on whether aggregation is enabled, and is | 888 | * The initial value depends on whether aggregation is enabled, and is |
1532 | * adjusted whenever underruns are detected. | 889 | * adjusted whenever underruns are detected. |
1533 | */ | 890 | */ |
1534 | REG_RMW_FIELD(ah, AR_TXCFG, AR_FTRIG, ah->tx_trig_level); | 891 | if (!AR_SREV_9300_20_OR_LATER(ah)) |
892 | REG_RMW_FIELD(ah, AR_TXCFG, AR_FTRIG, ah->tx_trig_level); | ||
893 | |||
894 | ENABLE_REGWRITE_BUFFER(ah); | ||
1535 | 895 | ||
1536 | /* | 896 | /* |
1537 | * let mac dma writes be in 128 byte chunks | 897 | * let mac dma writes be in 128 byte chunks |
@@ -1544,6 +904,14 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah) | |||
1544 | */ | 904 | */ |
1545 | REG_WRITE(ah, AR_RXFIFO_CFG, 0x200); | 905 | REG_WRITE(ah, AR_RXFIFO_CFG, 0x200); |
1546 | 906 | ||
907 | if (AR_SREV_9300_20_OR_LATER(ah)) { | ||
908 | REG_RMW_FIELD(ah, AR_RXBP_THRESH, AR_RXBP_THRESH_HP, 0x1); | ||
909 | REG_RMW_FIELD(ah, AR_RXBP_THRESH, AR_RXBP_THRESH_LP, 0x1); | ||
910 | |||
911 | ath9k_hw_set_rx_bufsize(ah, common->rx_bufsize - | ||
912 | ah->caps.rx_status_len); | ||
913 | } | ||
914 | |||
1547 | /* | 915 | /* |
1548 | * reduce the number of usable entries in PCU TXBUF to avoid | 916 | * reduce the number of usable entries in PCU TXBUF to avoid |
1549 | * wrap around issues. | 917 | * wrap around issues. |
@@ -1559,6 +927,12 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah) | |||
1559 | REG_WRITE(ah, AR_PCU_TXBUF_CTRL, | 927 | REG_WRITE(ah, AR_PCU_TXBUF_CTRL, |
1560 | AR_PCU_TXBUF_CTRL_USABLE_SIZE); | 928 | AR_PCU_TXBUF_CTRL_USABLE_SIZE); |
1561 | } | 929 | } |
930 | |||
931 | REGWRITE_BUFFER_FLUSH(ah); | ||
932 | DISABLE_REGWRITE_BUFFER(ah); | ||
933 | |||
934 | if (AR_SREV_9300_20_OR_LATER(ah)) | ||
935 | ath9k_hw_reset_txstatus_ring(ah); | ||
1562 | } | 936 | } |
1563 | 937 | ||
1564 | static void ath9k_hw_set_operating_mode(struct ath_hw *ah, int opmode) | 938 | static void ath9k_hw_set_operating_mode(struct ath_hw *ah, int opmode) |
@@ -1586,10 +960,8 @@ static void ath9k_hw_set_operating_mode(struct ath_hw *ah, int opmode) | |||
1586 | } | 960 | } |
1587 | } | 961 | } |
1588 | 962 | ||
1589 | static inline void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, | 963 | void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled, |
1590 | u32 coef_scaled, | 964 | u32 *coef_mantissa, u32 *coef_exponent) |
1591 | u32 *coef_mantissa, | ||
1592 | u32 *coef_exponent) | ||
1593 | { | 965 | { |
1594 | u32 coef_exp, coef_man; | 966 | u32 coef_exp, coef_man; |
1595 | 967 | ||
@@ -1605,40 +977,6 @@ static inline void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, | |||
1605 | *coef_exponent = coef_exp - 16; | 977 | *coef_exponent = coef_exp - 16; |
1606 | } | 978 | } |
1607 | 979 | ||
1608 | static void ath9k_hw_set_delta_slope(struct ath_hw *ah, | ||
1609 | struct ath9k_channel *chan) | ||
1610 | { | ||
1611 | u32 coef_scaled, ds_coef_exp, ds_coef_man; | ||
1612 | u32 clockMhzScaled = 0x64000000; | ||
1613 | struct chan_centers centers; | ||
1614 | |||
1615 | if (IS_CHAN_HALF_RATE(chan)) | ||
1616 | clockMhzScaled = clockMhzScaled >> 1; | ||
1617 | else if (IS_CHAN_QUARTER_RATE(chan)) | ||
1618 | clockMhzScaled = clockMhzScaled >> 2; | ||
1619 | |||
1620 | ath9k_hw_get_channel_centers(ah, chan, ¢ers); | ||
1621 | coef_scaled = clockMhzScaled / centers.synth_center; | ||
1622 | |||
1623 | ath9k_hw_get_delta_slope_vals(ah, coef_scaled, &ds_coef_man, | ||
1624 | &ds_coef_exp); | ||
1625 | |||
1626 | REG_RMW_FIELD(ah, AR_PHY_TIMING3, | ||
1627 | AR_PHY_TIMING3_DSC_MAN, ds_coef_man); | ||
1628 | REG_RMW_FIELD(ah, AR_PHY_TIMING3, | ||
1629 | AR_PHY_TIMING3_DSC_EXP, ds_coef_exp); | ||
1630 | |||
1631 | coef_scaled = (9 * coef_scaled) / 10; | ||
1632 | |||
1633 | ath9k_hw_get_delta_slope_vals(ah, coef_scaled, &ds_coef_man, | ||
1634 | &ds_coef_exp); | ||
1635 | |||
1636 | REG_RMW_FIELD(ah, AR_PHY_HALFGI, | ||
1637 | AR_PHY_HALFGI_DSC_MAN, ds_coef_man); | ||
1638 | REG_RMW_FIELD(ah, AR_PHY_HALFGI, | ||
1639 | AR_PHY_HALFGI_DSC_EXP, ds_coef_exp); | ||
1640 | } | ||
1641 | |||
1642 | static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) | 980 | static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) |
1643 | { | 981 | { |
1644 | u32 rst_flags; | 982 | u32 rst_flags; |
@@ -1652,6 +990,8 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) | |||
1652 | (void)REG_READ(ah, AR_RTC_DERIVED_CLK); | 990 | (void)REG_READ(ah, AR_RTC_DERIVED_CLK); |
1653 | } | 991 | } |
1654 | 992 | ||
993 | ENABLE_REGWRITE_BUFFER(ah); | ||
994 | |||
1655 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | | 995 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | |
1656 | AR_RTC_FORCE_WAKE_ON_INT); | 996 | AR_RTC_FORCE_WAKE_ON_INT); |
1657 | 997 | ||
@@ -1663,11 +1003,16 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) | |||
1663 | if (tmpReg & | 1003 | if (tmpReg & |
1664 | (AR_INTR_SYNC_LOCAL_TIMEOUT | | 1004 | (AR_INTR_SYNC_LOCAL_TIMEOUT | |
1665 | AR_INTR_SYNC_RADM_CPL_TIMEOUT)) { | 1005 | AR_INTR_SYNC_RADM_CPL_TIMEOUT)) { |
1006 | u32 val; | ||
1666 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0); | 1007 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0); |
1667 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); | 1008 | |
1668 | } else { | 1009 | val = AR_RC_HOSTIF; |
1010 | if (!AR_SREV_9300_20_OR_LATER(ah)) | ||
1011 | val |= AR_RC_AHB; | ||
1012 | REG_WRITE(ah, AR_RC, val); | ||
1013 | |||
1014 | } else if (!AR_SREV_9300_20_OR_LATER(ah)) | ||
1669 | REG_WRITE(ah, AR_RC, AR_RC_AHB); | 1015 | REG_WRITE(ah, AR_RC, AR_RC_AHB); |
1670 | } | ||
1671 | 1016 | ||
1672 | rst_flags = AR_RTC_RC_MAC_WARM; | 1017 | rst_flags = AR_RTC_RC_MAC_WARM; |
1673 | if (type == ATH9K_RESET_COLD) | 1018 | if (type == ATH9K_RESET_COLD) |
@@ -1675,6 +1020,10 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) | |||
1675 | } | 1020 | } |
1676 | 1021 | ||
1677 | REG_WRITE(ah, AR_RTC_RC, rst_flags); | 1022 | REG_WRITE(ah, AR_RTC_RC, rst_flags); |
1023 | |||
1024 | REGWRITE_BUFFER_FLUSH(ah); | ||
1025 | DISABLE_REGWRITE_BUFFER(ah); | ||
1026 | |||
1678 | udelay(50); | 1027 | udelay(50); |
1679 | 1028 | ||
1680 | REG_WRITE(ah, AR_RTC_RC, 0); | 1029 | REG_WRITE(ah, AR_RTC_RC, 0); |
@@ -1695,16 +1044,23 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) | |||
1695 | 1044 | ||
1696 | static bool ath9k_hw_set_reset_power_on(struct ath_hw *ah) | 1045 | static bool ath9k_hw_set_reset_power_on(struct ath_hw *ah) |
1697 | { | 1046 | { |
1047 | ENABLE_REGWRITE_BUFFER(ah); | ||
1048 | |||
1698 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | | 1049 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | |
1699 | AR_RTC_FORCE_WAKE_ON_INT); | 1050 | AR_RTC_FORCE_WAKE_ON_INT); |
1700 | 1051 | ||
1701 | if (!AR_SREV_9100(ah)) | 1052 | if (!AR_SREV_9100(ah) && !AR_SREV_9300_20_OR_LATER(ah)) |
1702 | REG_WRITE(ah, AR_RC, AR_RC_AHB); | 1053 | REG_WRITE(ah, AR_RC, AR_RC_AHB); |
1703 | 1054 | ||
1704 | REG_WRITE(ah, AR_RTC_RESET, 0); | 1055 | REG_WRITE(ah, AR_RTC_RESET, 0); |
1705 | udelay(2); | ||
1706 | 1056 | ||
1707 | if (!AR_SREV_9100(ah)) | 1057 | REGWRITE_BUFFER_FLUSH(ah); |
1058 | DISABLE_REGWRITE_BUFFER(ah); | ||
1059 | |||
1060 | if (!AR_SREV_9300_20_OR_LATER(ah)) | ||
1061 | udelay(2); | ||
1062 | |||
1063 | if (!AR_SREV_9100(ah) && !AR_SREV_9300_20_OR_LATER(ah)) | ||
1708 | REG_WRITE(ah, AR_RC, 0); | 1064 | REG_WRITE(ah, AR_RC, 0); |
1709 | 1065 | ||
1710 | REG_WRITE(ah, AR_RTC_RESET, 1); | 1066 | REG_WRITE(ah, AR_RTC_RESET, 1); |
@@ -1740,34 +1096,6 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type) | |||
1740 | } | 1096 | } |
1741 | } | 1097 | } |
1742 | 1098 | ||
1743 | static void ath9k_hw_set_regs(struct ath_hw *ah, struct ath9k_channel *chan) | ||
1744 | { | ||
1745 | u32 phymode; | ||
1746 | u32 enableDacFifo = 0; | ||
1747 | |||
1748 | if (AR_SREV_9285_10_OR_LATER(ah)) | ||
1749 | enableDacFifo = (REG_READ(ah, AR_PHY_TURBO) & | ||
1750 | AR_PHY_FC_ENABLE_DAC_FIFO); | ||
1751 | |||
1752 | phymode = AR_PHY_FC_HT_EN | AR_PHY_FC_SHORT_GI_40 | ||
1753 | | AR_PHY_FC_SINGLE_HT_LTF1 | AR_PHY_FC_WALSH | enableDacFifo; | ||
1754 | |||
1755 | if (IS_CHAN_HT40(chan)) { | ||
1756 | phymode |= AR_PHY_FC_DYN2040_EN; | ||
1757 | |||
1758 | if ((chan->chanmode == CHANNEL_A_HT40PLUS) || | ||
1759 | (chan->chanmode == CHANNEL_G_HT40PLUS)) | ||
1760 | phymode |= AR_PHY_FC_DYN2040_PRI_CH; | ||
1761 | |||
1762 | } | ||
1763 | REG_WRITE(ah, AR_PHY_TURBO, phymode); | ||
1764 | |||
1765 | ath9k_hw_set11nmac2040(ah); | ||
1766 | |||
1767 | REG_WRITE(ah, AR_GTXTO, 25 << AR_GTXTO_TIMEOUT_LIMIT_S); | ||
1768 | REG_WRITE(ah, AR_CST, 0xF << AR_CST_TIMEOUT_LIMIT_S); | ||
1769 | } | ||
1770 | |||
1771 | static bool ath9k_hw_chip_reset(struct ath_hw *ah, | 1099 | static bool ath9k_hw_chip_reset(struct ath_hw *ah, |
1772 | struct ath9k_channel *chan) | 1100 | struct ath9k_channel *chan) |
1773 | { | 1101 | { |
@@ -1793,7 +1121,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1793 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); | 1121 | struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); |
1794 | struct ath_common *common = ath9k_hw_common(ah); | 1122 | struct ath_common *common = ath9k_hw_common(ah); |
1795 | struct ieee80211_channel *channel = chan->chan; | 1123 | struct ieee80211_channel *channel = chan->chan; |
1796 | u32 synthDelay, qnum; | 1124 | u32 qnum; |
1797 | int r; | 1125 | int r; |
1798 | 1126 | ||
1799 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { | 1127 | for (qnum = 0; qnum < AR_NUM_QCU; qnum++) { |
@@ -1805,17 +1133,15 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1805 | } | 1133 | } |
1806 | } | 1134 | } |
1807 | 1135 | ||
1808 | REG_WRITE(ah, AR_PHY_RFBUS_REQ, AR_PHY_RFBUS_REQ_EN); | 1136 | if (!ath9k_hw_rfbus_req(ah)) { |
1809 | if (!ath9k_hw_wait(ah, AR_PHY_RFBUS_GRANT, AR_PHY_RFBUS_GRANT_EN, | ||
1810 | AR_PHY_RFBUS_GRANT_EN, AH_WAIT_TIMEOUT)) { | ||
1811 | ath_print(common, ATH_DBG_FATAL, | 1137 | ath_print(common, ATH_DBG_FATAL, |
1812 | "Could not kill baseband RX\n"); | 1138 | "Could not kill baseband RX\n"); |
1813 | return false; | 1139 | return false; |
1814 | } | 1140 | } |
1815 | 1141 | ||
1816 | ath9k_hw_set_regs(ah, chan); | 1142 | ath9k_hw_set_channel_regs(ah, chan); |
1817 | 1143 | ||
1818 | r = ah->ath9k_hw_rf_set_freq(ah, chan); | 1144 | r = ath9k_hw_rf_set_freq(ah, chan); |
1819 | if (r) { | 1145 | if (r) { |
1820 | ath_print(common, ATH_DBG_FATAL, | 1146 | ath_print(common, ATH_DBG_FATAL, |
1821 | "Failed to set channel\n"); | 1147 | "Failed to set channel\n"); |
@@ -1829,20 +1155,12 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1829 | min((u32) MAX_RATE_POWER, | 1155 | min((u32) MAX_RATE_POWER, |
1830 | (u32) regulatory->power_limit)); | 1156 | (u32) regulatory->power_limit)); |
1831 | 1157 | ||
1832 | synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY; | 1158 | ath9k_hw_rfbus_done(ah); |
1833 | if (IS_CHAN_B(chan)) | ||
1834 | synthDelay = (4 * synthDelay) / 22; | ||
1835 | else | ||
1836 | synthDelay /= 10; | ||
1837 | |||
1838 | udelay(synthDelay + BASE_ACTIVATE_DELAY); | ||
1839 | |||
1840 | REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0); | ||
1841 | 1159 | ||
1842 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) | 1160 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) |
1843 | ath9k_hw_set_delta_slope(ah, chan); | 1161 | ath9k_hw_set_delta_slope(ah, chan); |
1844 | 1162 | ||
1845 | ah->ath9k_hw_spur_mitigate_freq(ah, chan); | 1163 | ath9k_hw_spur_mitigate_freq(ah, chan); |
1846 | 1164 | ||
1847 | if (!chan->oneTimeCalsDone) | 1165 | if (!chan->oneTimeCalsDone) |
1848 | chan->oneTimeCalsDone = true; | 1166 | chan->oneTimeCalsDone = true; |
@@ -1850,17 +1168,33 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, | |||
1850 | return true; | 1168 | return true; |
1851 | } | 1169 | } |
1852 | 1170 | ||
1853 | static void ath9k_enable_rfkill(struct ath_hw *ah) | 1171 | bool ath9k_hw_check_alive(struct ath_hw *ah) |
1854 | { | 1172 | { |
1855 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, | 1173 | int count = 50; |
1856 | AR_GPIO_INPUT_EN_VAL_RFSILENT_BB); | 1174 | u32 reg; |
1175 | |||
1176 | if (AR_SREV_9285_10_OR_LATER(ah)) | ||
1177 | return true; | ||
1178 | |||
1179 | do { | ||
1180 | reg = REG_READ(ah, AR_OBS_BUS_1); | ||
1857 | 1181 | ||
1858 | REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2, | 1182 | if ((reg & 0x7E7FFFEF) == 0x00702400) |
1859 | AR_GPIO_INPUT_MUX2_RFSILENT); | 1183 | continue; |
1860 | 1184 | ||
1861 | ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio); | 1185 | switch (reg & 0x7E000B00) { |
1862 | REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB); | 1186 | case 0x1E000000: |
1187 | case 0x52000B00: | ||
1188 | case 0x18000B00: | ||
1189 | continue; | ||
1190 | default: | ||
1191 | return true; | ||
1192 | } | ||
1193 | } while (count-- > 0); | ||
1194 | |||
1195 | return false; | ||
1863 | } | 1196 | } |
1197 | EXPORT_SYMBOL(ath9k_hw_check_alive); | ||
1864 | 1198 | ||
1865 | int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | 1199 | int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, |
1866 | bool bChannelChange) | 1200 | bool bChannelChange) |
@@ -1871,11 +1205,18 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1871 | u32 saveDefAntenna; | 1205 | u32 saveDefAntenna; |
1872 | u32 macStaId1; | 1206 | u32 macStaId1; |
1873 | u64 tsf = 0; | 1207 | u64 tsf = 0; |
1874 | int i, rx_chainmask, r; | 1208 | int i, r; |
1875 | 1209 | ||
1876 | ah->txchainmask = common->tx_chainmask; | 1210 | ah->txchainmask = common->tx_chainmask; |
1877 | ah->rxchainmask = common->rx_chainmask; | 1211 | ah->rxchainmask = common->rx_chainmask; |
1878 | 1212 | ||
1213 | if (!ah->chip_fullsleep) { | ||
1214 | ath9k_hw_abortpcurecv(ah); | ||
1215 | if (!ath9k_hw_stopdmarecv(ah)) | ||
1216 | ath_print(common, ATH_DBG_XMIT, | ||
1217 | "Failed to stop receive dma\n"); | ||
1218 | } | ||
1219 | |||
1879 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) | 1220 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) |
1880 | return -EIO; | 1221 | return -EIO; |
1881 | 1222 | ||
@@ -1888,8 +1229,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1888 | (chan->channel != ah->curchan->channel) && | 1229 | (chan->channel != ah->curchan->channel) && |
1889 | ((chan->channelFlags & CHANNEL_ALL) == | 1230 | ((chan->channelFlags & CHANNEL_ALL) == |
1890 | (ah->curchan->channelFlags & CHANNEL_ALL)) && | 1231 | (ah->curchan->channelFlags & CHANNEL_ALL)) && |
1891 | !(AR_SREV_9280(ah) || IS_CHAN_A_5MHZ_SPACED(chan) || | 1232 | !AR_SREV_9280(ah)) { |
1892 | IS_CHAN_A_5MHZ_SPACED(ah->curchan))) { | ||
1893 | 1233 | ||
1894 | if (ath9k_hw_channel_change(ah, chan)) { | 1234 | if (ath9k_hw_channel_change(ah, chan)) { |
1895 | ath9k_hw_loadnf(ah, ah->curchan); | 1235 | ath9k_hw_loadnf(ah, ah->curchan); |
@@ -1943,16 +1283,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1943 | if (AR_SREV_9280_10_OR_LATER(ah)) | 1283 | if (AR_SREV_9280_10_OR_LATER(ah)) |
1944 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE); | 1284 | REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE); |
1945 | 1285 | ||
1946 | if (AR_SREV_9287_12_OR_LATER(ah)) { | ||
1947 | /* Enable ASYNC FIFO */ | ||
1948 | REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, | ||
1949 | AR_MAC_PCU_ASYNC_FIFO_REG3_DATAPATH_SEL); | ||
1950 | REG_SET_BIT(ah, AR_PHY_MODE, AR_PHY_MODE_ASYNCFIFO); | ||
1951 | REG_CLR_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, | ||
1952 | AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET); | ||
1953 | REG_SET_BIT(ah, AR_MAC_PCU_ASYNC_FIFO_REG3, | ||
1954 | AR_MAC_PCU_ASYNC_FIFO_REG3_SOFT_RESET); | ||
1955 | } | ||
1956 | r = ath9k_hw_process_ini(ah, chan); | 1286 | r = ath9k_hw_process_ini(ah, chan); |
1957 | if (r) | 1287 | if (r) |
1958 | return r; | 1288 | return r; |
@@ -1977,9 +1307,13 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1977 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) | 1307 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) |
1978 | ath9k_hw_set_delta_slope(ah, chan); | 1308 | ath9k_hw_set_delta_slope(ah, chan); |
1979 | 1309 | ||
1980 | ah->ath9k_hw_spur_mitigate_freq(ah, chan); | 1310 | ath9k_hw_spur_mitigate_freq(ah, chan); |
1981 | ah->eep_ops->set_board_values(ah, chan); | 1311 | ah->eep_ops->set_board_values(ah, chan); |
1982 | 1312 | ||
1313 | ath9k_hw_set_operating_mode(ah, ah->opmode); | ||
1314 | |||
1315 | ENABLE_REGWRITE_BUFFER(ah); | ||
1316 | |||
1983 | REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr)); | 1317 | REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr)); |
1984 | REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4) | 1318 | REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4) |
1985 | | macStaId1 | 1319 | | macStaId1 |
@@ -1987,25 +1321,27 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1987 | | (ah->config. | 1321 | | (ah->config. |
1988 | ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0) | 1322 | ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0) |
1989 | | ah->sta_id1_defaults); | 1323 | | ah->sta_id1_defaults); |
1990 | ath9k_hw_set_operating_mode(ah, ah->opmode); | ||
1991 | |||
1992 | ath_hw_setbssidmask(common); | 1324 | ath_hw_setbssidmask(common); |
1993 | |||
1994 | REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna); | 1325 | REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna); |
1995 | |||
1996 | ath9k_hw_write_associd(ah); | 1326 | ath9k_hw_write_associd(ah); |
1997 | |||
1998 | REG_WRITE(ah, AR_ISR, ~0); | 1327 | REG_WRITE(ah, AR_ISR, ~0); |
1999 | |||
2000 | REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); | 1328 | REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); |
2001 | 1329 | ||
2002 | r = ah->ath9k_hw_rf_set_freq(ah, chan); | 1330 | REGWRITE_BUFFER_FLUSH(ah); |
1331 | DISABLE_REGWRITE_BUFFER(ah); | ||
1332 | |||
1333 | r = ath9k_hw_rf_set_freq(ah, chan); | ||
2003 | if (r) | 1334 | if (r) |
2004 | return r; | 1335 | return r; |
2005 | 1336 | ||
1337 | ENABLE_REGWRITE_BUFFER(ah); | ||
1338 | |||
2006 | for (i = 0; i < AR_NUM_DCU; i++) | 1339 | for (i = 0; i < AR_NUM_DCU; i++) |
2007 | REG_WRITE(ah, AR_DQCUMASK(i), 1 << i); | 1340 | REG_WRITE(ah, AR_DQCUMASK(i), 1 << i); |
2008 | 1341 | ||
1342 | REGWRITE_BUFFER_FLUSH(ah); | ||
1343 | DISABLE_REGWRITE_BUFFER(ah); | ||
1344 | |||
2009 | ah->intr_txqs = 0; | 1345 | ah->intr_txqs = 0; |
2010 | for (i = 0; i < ah->caps.total_queues; i++) | 1346 | for (i = 0; i < ah->caps.total_queues; i++) |
2011 | ath9k_hw_resettxqueue(ah, i); | 1347 | ath9k_hw_resettxqueue(ah, i); |
@@ -2018,25 +1354,9 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2018 | 1354 | ||
2019 | ath9k_hw_init_global_settings(ah); | 1355 | ath9k_hw_init_global_settings(ah); |
2020 | 1356 | ||
2021 | if (AR_SREV_9287_12_OR_LATER(ah)) { | 1357 | if (!AR_SREV_9300_20_OR_LATER(ah)) { |
2022 | REG_WRITE(ah, AR_D_GBL_IFS_SIFS, | 1358 | ar9002_hw_enable_async_fifo(ah); |
2023 | AR_D_GBL_IFS_SIFS_ASYNC_FIFO_DUR); | 1359 | ar9002_hw_enable_wep_aggregation(ah); |
2024 | REG_WRITE(ah, AR_D_GBL_IFS_SLOT, | ||
2025 | AR_D_GBL_IFS_SLOT_ASYNC_FIFO_DUR); | ||
2026 | REG_WRITE(ah, AR_D_GBL_IFS_EIFS, | ||
2027 | AR_D_GBL_IFS_EIFS_ASYNC_FIFO_DUR); | ||
2028 | |||
2029 | REG_WRITE(ah, AR_TIME_OUT, AR_TIME_OUT_ACK_CTS_ASYNC_FIFO_DUR); | ||
2030 | REG_WRITE(ah, AR_USEC, AR_USEC_ASYNC_FIFO_DUR); | ||
2031 | |||
2032 | REG_SET_BIT(ah, AR_MAC_PCU_LOGIC_ANALYZER, | ||
2033 | AR_MAC_PCU_LOGIC_ANALYZER_DISBUG20768); | ||
2034 | REG_RMW_FIELD(ah, AR_AHB_MODE, AR_AHB_CUSTOM_BURST_EN, | ||
2035 | AR_AHB_CUSTOM_BURST_ASYNC_FIFO_VAL); | ||
2036 | } | ||
2037 | if (AR_SREV_9287_12_OR_LATER(ah)) { | ||
2038 | REG_SET_BIT(ah, AR_PCU_MISC_MODE2, | ||
2039 | AR_PCU_MISC_MODE2_ENABLE_AGGWEP); | ||
2040 | } | 1360 | } |
2041 | 1361 | ||
2042 | REG_WRITE(ah, AR_STA_ID1, | 1362 | REG_WRITE(ah, AR_STA_ID1, |
@@ -2051,19 +1371,24 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2051 | REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000); | 1371 | REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000); |
2052 | } | 1372 | } |
2053 | 1373 | ||
1374 | if (ah->config.tx_intr_mitigation) { | ||
1375 | REG_RMW_FIELD(ah, AR_TIMT, AR_TIMT_LAST, 300); | ||
1376 | REG_RMW_FIELD(ah, AR_TIMT, AR_TIMT_FIRST, 750); | ||
1377 | } | ||
1378 | |||
2054 | ath9k_hw_init_bb(ah, chan); | 1379 | ath9k_hw_init_bb(ah, chan); |
2055 | 1380 | ||
2056 | if (!ath9k_hw_init_cal(ah, chan)) | 1381 | if (!ath9k_hw_init_cal(ah, chan)) |
2057 | return -EIO; | 1382 | return -EIO; |
2058 | 1383 | ||
2059 | rx_chainmask = ah->rxchainmask; | 1384 | ENABLE_REGWRITE_BUFFER(ah); |
2060 | if ((rx_chainmask == 0x5) || (rx_chainmask == 0x3)) { | ||
2061 | REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx_chainmask); | ||
2062 | REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx_chainmask); | ||
2063 | } | ||
2064 | 1385 | ||
1386 | ath9k_hw_restore_chainmask(ah); | ||
2065 | REG_WRITE(ah, AR_CFG_LED, saveLedState | AR_CFG_SCLK_32KHZ); | 1387 | REG_WRITE(ah, AR_CFG_LED, saveLedState | AR_CFG_SCLK_32KHZ); |
2066 | 1388 | ||
1389 | REGWRITE_BUFFER_FLUSH(ah); | ||
1390 | DISABLE_REGWRITE_BUFFER(ah); | ||
1391 | |||
2067 | /* | 1392 | /* |
2068 | * For big endian systems turn on swapping for descriptors | 1393 | * For big endian systems turn on swapping for descriptors |
2069 | */ | 1394 | */ |
@@ -2093,6 +1418,11 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2093 | if (ah->btcoex_hw.enabled) | 1418 | if (ah->btcoex_hw.enabled) |
2094 | ath9k_hw_btcoex_enable(ah); | 1419 | ath9k_hw_btcoex_enable(ah); |
2095 | 1420 | ||
1421 | if (AR_SREV_9300_20_OR_LATER(ah)) { | ||
1422 | ath9k_hw_loadnf(ah, curchan); | ||
1423 | ath9k_hw_start_nfcal(ah); | ||
1424 | } | ||
1425 | |||
2096 | return 0; | 1426 | return 0; |
2097 | } | 1427 | } |
2098 | EXPORT_SYMBOL(ath9k_hw_reset); | 1428 | EXPORT_SYMBOL(ath9k_hw_reset); |
@@ -2379,21 +1709,35 @@ EXPORT_SYMBOL(ath9k_hw_keyisvalid); | |||
2379 | /* Power Management (Chipset) */ | 1709 | /* Power Management (Chipset) */ |
2380 | /******************************/ | 1710 | /******************************/ |
2381 | 1711 | ||
1712 | /* | ||
1713 | * Notify Power Mgt is disabled in self-generated frames. | ||
1714 | * If requested, force chip to sleep. | ||
1715 | */ | ||
2382 | static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip) | 1716 | static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip) |
2383 | { | 1717 | { |
2384 | REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); | 1718 | REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); |
2385 | if (setChip) { | 1719 | if (setChip) { |
1720 | /* | ||
1721 | * Clear the RTC force wake bit to allow the | ||
1722 | * mac to go to sleep. | ||
1723 | */ | ||
2386 | REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, | 1724 | REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, |
2387 | AR_RTC_FORCE_WAKE_EN); | 1725 | AR_RTC_FORCE_WAKE_EN); |
2388 | if (!AR_SREV_9100(ah)) | 1726 | if (!AR_SREV_9100(ah) && !AR_SREV_9300_20_OR_LATER(ah)) |
2389 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); | 1727 | REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); |
2390 | 1728 | ||
1729 | /* Shutdown chip. Active low */ | ||
2391 | if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah)) | 1730 | if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah)) |
2392 | REG_CLR_BIT(ah, (AR_RTC_RESET), | 1731 | REG_CLR_BIT(ah, (AR_RTC_RESET), |
2393 | AR_RTC_RESET_EN); | 1732 | AR_RTC_RESET_EN); |
2394 | } | 1733 | } |
2395 | } | 1734 | } |
2396 | 1735 | ||
1736 | /* | ||
1737 | * Notify Power Management is enabled in self-generating | ||
1738 | * frames. If request, set power mode of chip to | ||
1739 | * auto/normal. Duration in units of 128us (1/8 TU). | ||
1740 | */ | ||
2397 | static void ath9k_set_power_network_sleep(struct ath_hw *ah, int setChip) | 1741 | static void ath9k_set_power_network_sleep(struct ath_hw *ah, int setChip) |
2398 | { | 1742 | { |
2399 | REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); | 1743 | REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV); |
@@ -2401,9 +1745,14 @@ static void ath9k_set_power_network_sleep(struct ath_hw *ah, int setChip) | |||
2401 | struct ath9k_hw_capabilities *pCap = &ah->caps; | 1745 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
2402 | 1746 | ||
2403 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { | 1747 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
1748 | /* Set WakeOnInterrupt bit; clear ForceWake bit */ | ||
2404 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, | 1749 | REG_WRITE(ah, AR_RTC_FORCE_WAKE, |
2405 | AR_RTC_FORCE_WAKE_ON_INT); | 1750 | AR_RTC_FORCE_WAKE_ON_INT); |
2406 | } else { | 1751 | } else { |
1752 | /* | ||
1753 | * Clear the RTC force wake bit to allow the | ||
1754 | * mac to go to sleep. | ||
1755 | */ | ||
2407 | REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, | 1756 | REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, |
2408 | AR_RTC_FORCE_WAKE_EN); | 1757 | AR_RTC_FORCE_WAKE_EN); |
2409 | } | 1758 | } |
@@ -2422,7 +1771,8 @@ static bool ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip) | |||
2422 | ATH9K_RESET_POWER_ON) != true) { | 1771 | ATH9K_RESET_POWER_ON) != true) { |
2423 | return false; | 1772 | return false; |
2424 | } | 1773 | } |
2425 | ath9k_hw_init_pll(ah, NULL); | 1774 | if (!AR_SREV_9300_20_OR_LATER(ah)) |
1775 | ath9k_hw_init_pll(ah, NULL); | ||
2426 | } | 1776 | } |
2427 | if (AR_SREV_9100(ah)) | 1777 | if (AR_SREV_9100(ah)) |
2428 | REG_SET_BIT(ah, AR_RTC_RESET, | 1778 | REG_SET_BIT(ah, AR_RTC_RESET, |
@@ -2492,420 +1842,6 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode) | |||
2492 | } | 1842 | } |
2493 | EXPORT_SYMBOL(ath9k_hw_setpower); | 1843 | EXPORT_SYMBOL(ath9k_hw_setpower); |
2494 | 1844 | ||
2495 | /* | ||
2496 | * Helper for ASPM support. | ||
2497 | * | ||
2498 | * Disable PLL when in L0s as well as receiver clock when in L1. | ||
2499 | * This power saving option must be enabled through the SerDes. | ||
2500 | * | ||
2501 | * Programming the SerDes must go through the same 288 bit serial shift | ||
2502 | * register as the other analog registers. Hence the 9 writes. | ||
2503 | */ | ||
2504 | void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off) | ||
2505 | { | ||
2506 | u8 i; | ||
2507 | u32 val; | ||
2508 | |||
2509 | if (ah->is_pciexpress != true) | ||
2510 | return; | ||
2511 | |||
2512 | /* Do not touch SerDes registers */ | ||
2513 | if (ah->config.pcie_powersave_enable == 2) | ||
2514 | return; | ||
2515 | |||
2516 | /* Nothing to do on restore for 11N */ | ||
2517 | if (!restore) { | ||
2518 | if (AR_SREV_9280_20_OR_LATER(ah)) { | ||
2519 | /* | ||
2520 | * AR9280 2.0 or later chips use SerDes values from the | ||
2521 | * initvals.h initialized depending on chipset during | ||
2522 | * ath9k_hw_init() | ||
2523 | */ | ||
2524 | for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) { | ||
2525 | REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0), | ||
2526 | INI_RA(&ah->iniPcieSerdes, i, 1)); | ||
2527 | } | ||
2528 | } else if (AR_SREV_9280(ah) && | ||
2529 | (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) { | ||
2530 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00); | ||
2531 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); | ||
2532 | |||
2533 | /* RX shut off when elecidle is asserted */ | ||
2534 | REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019); | ||
2535 | REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820); | ||
2536 | REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560); | ||
2537 | |||
2538 | /* Shut off CLKREQ active in L1 */ | ||
2539 | if (ah->config.pcie_clock_req) | ||
2540 | REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc); | ||
2541 | else | ||
2542 | REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd); | ||
2543 | |||
2544 | REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); | ||
2545 | REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); | ||
2546 | REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007); | ||
2547 | |||
2548 | /* Load the new settings */ | ||
2549 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); | ||
2550 | |||
2551 | } else { | ||
2552 | REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); | ||
2553 | REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); | ||
2554 | |||
2555 | /* RX shut off when elecidle is asserted */ | ||
2556 | REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039); | ||
2557 | REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824); | ||
2558 | REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579); | ||
2559 | |||
2560 | /* | ||
2561 | * Ignore ah->ah_config.pcie_clock_req setting for | ||
2562 | * pre-AR9280 11n | ||
2563 | */ | ||
2564 | REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff); | ||
2565 | |||
2566 | REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); | ||
2567 | REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554); | ||
2568 | REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007); | ||
2569 | |||
2570 | /* Load the new settings */ | ||
2571 | REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); | ||
2572 | } | ||
2573 | |||
2574 | udelay(1000); | ||
2575 | |||
2576 | /* set bit 19 to allow forcing of pcie core into L1 state */ | ||
2577 | REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); | ||
2578 | |||
2579 | /* Several PCIe massages to ensure proper behaviour */ | ||
2580 | if (ah->config.pcie_waen) { | ||
2581 | val = ah->config.pcie_waen; | ||
2582 | if (!power_off) | ||
2583 | val &= (~AR_WA_D3_L1_DISABLE); | ||
2584 | } else { | ||
2585 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || | ||
2586 | AR_SREV_9287(ah)) { | ||
2587 | val = AR9285_WA_DEFAULT; | ||
2588 | if (!power_off) | ||
2589 | val &= (~AR_WA_D3_L1_DISABLE); | ||
2590 | } else if (AR_SREV_9280(ah)) { | ||
2591 | /* | ||
2592 | * On AR9280 chips bit 22 of 0x4004 needs to be | ||
2593 | * set otherwise card may disappear. | ||
2594 | */ | ||
2595 | val = AR9280_WA_DEFAULT; | ||
2596 | if (!power_off) | ||
2597 | val &= (~AR_WA_D3_L1_DISABLE); | ||
2598 | } else | ||
2599 | val = AR_WA_DEFAULT; | ||
2600 | } | ||
2601 | |||
2602 | REG_WRITE(ah, AR_WA, val); | ||
2603 | } | ||
2604 | |||
2605 | if (power_off) { | ||
2606 | /* | ||
2607 | * Set PCIe workaround bits | ||
2608 | * bit 14 in WA register (disable L1) should only | ||
2609 | * be set when device enters D3 and be cleared | ||
2610 | * when device comes back to D0. | ||
2611 | */ | ||
2612 | if (ah->config.pcie_waen) { | ||
2613 | if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE) | ||
2614 | REG_SET_BIT(ah, AR_WA, AR_WA_D3_L1_DISABLE); | ||
2615 | } else { | ||
2616 | if (((AR_SREV_9285(ah) || AR_SREV_9271(ah) || | ||
2617 | AR_SREV_9287(ah)) && | ||
2618 | (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) || | ||
2619 | (AR_SREV_9280(ah) && | ||
2620 | (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) { | ||
2621 | REG_SET_BIT(ah, AR_WA, AR_WA_D3_L1_DISABLE); | ||
2622 | } | ||
2623 | } | ||
2624 | } | ||
2625 | } | ||
2626 | EXPORT_SYMBOL(ath9k_hw_configpcipowersave); | ||
2627 | |||
2628 | /**********************/ | ||
2629 | /* Interrupt Handling */ | ||
2630 | /**********************/ | ||
2631 | |||
2632 | bool ath9k_hw_intrpend(struct ath_hw *ah) | ||
2633 | { | ||
2634 | u32 host_isr; | ||
2635 | |||
2636 | if (AR_SREV_9100(ah)) | ||
2637 | return true; | ||
2638 | |||
2639 | host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE); | ||
2640 | if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS)) | ||
2641 | return true; | ||
2642 | |||
2643 | host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE); | ||
2644 | if ((host_isr & AR_INTR_SYNC_DEFAULT) | ||
2645 | && (host_isr != AR_INTR_SPURIOUS)) | ||
2646 | return true; | ||
2647 | |||
2648 | return false; | ||
2649 | } | ||
2650 | EXPORT_SYMBOL(ath9k_hw_intrpend); | ||
2651 | |||
2652 | bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked) | ||
2653 | { | ||
2654 | u32 isr = 0; | ||
2655 | u32 mask2 = 0; | ||
2656 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
2657 | u32 sync_cause = 0; | ||
2658 | bool fatal_int = false; | ||
2659 | struct ath_common *common = ath9k_hw_common(ah); | ||
2660 | |||
2661 | if (!AR_SREV_9100(ah)) { | ||
2662 | if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) { | ||
2663 | if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) | ||
2664 | == AR_RTC_STATUS_ON) { | ||
2665 | isr = REG_READ(ah, AR_ISR); | ||
2666 | } | ||
2667 | } | ||
2668 | |||
2669 | sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) & | ||
2670 | AR_INTR_SYNC_DEFAULT; | ||
2671 | |||
2672 | *masked = 0; | ||
2673 | |||
2674 | if (!isr && !sync_cause) | ||
2675 | return false; | ||
2676 | } else { | ||
2677 | *masked = 0; | ||
2678 | isr = REG_READ(ah, AR_ISR); | ||
2679 | } | ||
2680 | |||
2681 | if (isr) { | ||
2682 | if (isr & AR_ISR_BCNMISC) { | ||
2683 | u32 isr2; | ||
2684 | isr2 = REG_READ(ah, AR_ISR_S2); | ||
2685 | if (isr2 & AR_ISR_S2_TIM) | ||
2686 | mask2 |= ATH9K_INT_TIM; | ||
2687 | if (isr2 & AR_ISR_S2_DTIM) | ||
2688 | mask2 |= ATH9K_INT_DTIM; | ||
2689 | if (isr2 & AR_ISR_S2_DTIMSYNC) | ||
2690 | mask2 |= ATH9K_INT_DTIMSYNC; | ||
2691 | if (isr2 & (AR_ISR_S2_CABEND)) | ||
2692 | mask2 |= ATH9K_INT_CABEND; | ||
2693 | if (isr2 & AR_ISR_S2_GTT) | ||
2694 | mask2 |= ATH9K_INT_GTT; | ||
2695 | if (isr2 & AR_ISR_S2_CST) | ||
2696 | mask2 |= ATH9K_INT_CST; | ||
2697 | if (isr2 & AR_ISR_S2_TSFOOR) | ||
2698 | mask2 |= ATH9K_INT_TSFOOR; | ||
2699 | } | ||
2700 | |||
2701 | isr = REG_READ(ah, AR_ISR_RAC); | ||
2702 | if (isr == 0xffffffff) { | ||
2703 | *masked = 0; | ||
2704 | return false; | ||
2705 | } | ||
2706 | |||
2707 | *masked = isr & ATH9K_INT_COMMON; | ||
2708 | |||
2709 | if (ah->config.rx_intr_mitigation) { | ||
2710 | if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) | ||
2711 | *masked |= ATH9K_INT_RX; | ||
2712 | } | ||
2713 | |||
2714 | if (isr & (AR_ISR_RXOK | AR_ISR_RXERR)) | ||
2715 | *masked |= ATH9K_INT_RX; | ||
2716 | if (isr & | ||
2717 | (AR_ISR_TXOK | AR_ISR_TXDESC | AR_ISR_TXERR | | ||
2718 | AR_ISR_TXEOL)) { | ||
2719 | u32 s0_s, s1_s; | ||
2720 | |||
2721 | *masked |= ATH9K_INT_TX; | ||
2722 | |||
2723 | s0_s = REG_READ(ah, AR_ISR_S0_S); | ||
2724 | ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXOK); | ||
2725 | ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXDESC); | ||
2726 | |||
2727 | s1_s = REG_READ(ah, AR_ISR_S1_S); | ||
2728 | ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXERR); | ||
2729 | ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXEOL); | ||
2730 | } | ||
2731 | |||
2732 | if (isr & AR_ISR_RXORN) { | ||
2733 | ath_print(common, ATH_DBG_INTERRUPT, | ||
2734 | "receive FIFO overrun interrupt\n"); | ||
2735 | } | ||
2736 | |||
2737 | if (!AR_SREV_9100(ah)) { | ||
2738 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { | ||
2739 | u32 isr5 = REG_READ(ah, AR_ISR_S5_S); | ||
2740 | if (isr5 & AR_ISR_S5_TIM_TIMER) | ||
2741 | *masked |= ATH9K_INT_TIM_TIMER; | ||
2742 | } | ||
2743 | } | ||
2744 | |||
2745 | *masked |= mask2; | ||
2746 | } | ||
2747 | |||
2748 | if (AR_SREV_9100(ah)) | ||
2749 | return true; | ||
2750 | |||
2751 | if (isr & AR_ISR_GENTMR) { | ||
2752 | u32 s5_s; | ||
2753 | |||
2754 | s5_s = REG_READ(ah, AR_ISR_S5_S); | ||
2755 | if (isr & AR_ISR_GENTMR) { | ||
2756 | ah->intr_gen_timer_trigger = | ||
2757 | MS(s5_s, AR_ISR_S5_GENTIMER_TRIG); | ||
2758 | |||
2759 | ah->intr_gen_timer_thresh = | ||
2760 | MS(s5_s, AR_ISR_S5_GENTIMER_THRESH); | ||
2761 | |||
2762 | if (ah->intr_gen_timer_trigger) | ||
2763 | *masked |= ATH9K_INT_GENTIMER; | ||
2764 | |||
2765 | } | ||
2766 | } | ||
2767 | |||
2768 | if (sync_cause) { | ||
2769 | fatal_int = | ||
2770 | (sync_cause & | ||
2771 | (AR_INTR_SYNC_HOST1_FATAL | AR_INTR_SYNC_HOST1_PERR)) | ||
2772 | ? true : false; | ||
2773 | |||
2774 | if (fatal_int) { | ||
2775 | if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) { | ||
2776 | ath_print(common, ATH_DBG_ANY, | ||
2777 | "received PCI FATAL interrupt\n"); | ||
2778 | } | ||
2779 | if (sync_cause & AR_INTR_SYNC_HOST1_PERR) { | ||
2780 | ath_print(common, ATH_DBG_ANY, | ||
2781 | "received PCI PERR interrupt\n"); | ||
2782 | } | ||
2783 | *masked |= ATH9K_INT_FATAL; | ||
2784 | } | ||
2785 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) { | ||
2786 | ath_print(common, ATH_DBG_INTERRUPT, | ||
2787 | "AR_INTR_SYNC_RADM_CPL_TIMEOUT\n"); | ||
2788 | REG_WRITE(ah, AR_RC, AR_RC_HOSTIF); | ||
2789 | REG_WRITE(ah, AR_RC, 0); | ||
2790 | *masked |= ATH9K_INT_FATAL; | ||
2791 | } | ||
2792 | if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) { | ||
2793 | ath_print(common, ATH_DBG_INTERRUPT, | ||
2794 | "AR_INTR_SYNC_LOCAL_TIMEOUT\n"); | ||
2795 | } | ||
2796 | |||
2797 | REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause); | ||
2798 | (void) REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR); | ||
2799 | } | ||
2800 | |||
2801 | return true; | ||
2802 | } | ||
2803 | EXPORT_SYMBOL(ath9k_hw_getisr); | ||
2804 | |||
2805 | enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints) | ||
2806 | { | ||
2807 | enum ath9k_int omask = ah->imask; | ||
2808 | u32 mask, mask2; | ||
2809 | struct ath9k_hw_capabilities *pCap = &ah->caps; | ||
2810 | struct ath_common *common = ath9k_hw_common(ah); | ||
2811 | |||
2812 | ath_print(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints); | ||
2813 | |||
2814 | if (omask & ATH9K_INT_GLOBAL) { | ||
2815 | ath_print(common, ATH_DBG_INTERRUPT, "disable IER\n"); | ||
2816 | REG_WRITE(ah, AR_IER, AR_IER_DISABLE); | ||
2817 | (void) REG_READ(ah, AR_IER); | ||
2818 | if (!AR_SREV_9100(ah)) { | ||
2819 | REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0); | ||
2820 | (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE); | ||
2821 | |||
2822 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0); | ||
2823 | (void) REG_READ(ah, AR_INTR_SYNC_ENABLE); | ||
2824 | } | ||
2825 | } | ||
2826 | |||
2827 | mask = ints & ATH9K_INT_COMMON; | ||
2828 | mask2 = 0; | ||
2829 | |||
2830 | if (ints & ATH9K_INT_TX) { | ||
2831 | if (ah->txok_interrupt_mask) | ||
2832 | mask |= AR_IMR_TXOK; | ||
2833 | if (ah->txdesc_interrupt_mask) | ||
2834 | mask |= AR_IMR_TXDESC; | ||
2835 | if (ah->txerr_interrupt_mask) | ||
2836 | mask |= AR_IMR_TXERR; | ||
2837 | if (ah->txeol_interrupt_mask) | ||
2838 | mask |= AR_IMR_TXEOL; | ||
2839 | } | ||
2840 | if (ints & ATH9K_INT_RX) { | ||
2841 | mask |= AR_IMR_RXERR; | ||
2842 | if (ah->config.rx_intr_mitigation) | ||
2843 | mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM; | ||
2844 | else | ||
2845 | mask |= AR_IMR_RXOK | AR_IMR_RXDESC; | ||
2846 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) | ||
2847 | mask |= AR_IMR_GENTMR; | ||
2848 | } | ||
2849 | |||
2850 | if (ints & (ATH9K_INT_BMISC)) { | ||
2851 | mask |= AR_IMR_BCNMISC; | ||
2852 | if (ints & ATH9K_INT_TIM) | ||
2853 | mask2 |= AR_IMR_S2_TIM; | ||
2854 | if (ints & ATH9K_INT_DTIM) | ||
2855 | mask2 |= AR_IMR_S2_DTIM; | ||
2856 | if (ints & ATH9K_INT_DTIMSYNC) | ||
2857 | mask2 |= AR_IMR_S2_DTIMSYNC; | ||
2858 | if (ints & ATH9K_INT_CABEND) | ||
2859 | mask2 |= AR_IMR_S2_CABEND; | ||
2860 | if (ints & ATH9K_INT_TSFOOR) | ||
2861 | mask2 |= AR_IMR_S2_TSFOOR; | ||
2862 | } | ||
2863 | |||
2864 | if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) { | ||
2865 | mask |= AR_IMR_BCNMISC; | ||
2866 | if (ints & ATH9K_INT_GTT) | ||
2867 | mask2 |= AR_IMR_S2_GTT; | ||
2868 | if (ints & ATH9K_INT_CST) | ||
2869 | mask2 |= AR_IMR_S2_CST; | ||
2870 | } | ||
2871 | |||
2872 | ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask); | ||
2873 | REG_WRITE(ah, AR_IMR, mask); | ||
2874 | ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC | | ||
2875 | AR_IMR_S2_CABEND | AR_IMR_S2_CABTO | | ||
2876 | AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST); | ||
2877 | ah->imrs2_reg |= mask2; | ||
2878 | REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg); | ||
2879 | |||
2880 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { | ||
2881 | if (ints & ATH9K_INT_TIM_TIMER) | ||
2882 | REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER); | ||
2883 | else | ||
2884 | REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER); | ||
2885 | } | ||
2886 | |||
2887 | if (ints & ATH9K_INT_GLOBAL) { | ||
2888 | ath_print(common, ATH_DBG_INTERRUPT, "enable IER\n"); | ||
2889 | REG_WRITE(ah, AR_IER, AR_IER_ENABLE); | ||
2890 | if (!AR_SREV_9100(ah)) { | ||
2891 | REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, | ||
2892 | AR_INTR_MAC_IRQ); | ||
2893 | REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ); | ||
2894 | |||
2895 | |||
2896 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, | ||
2897 | AR_INTR_SYNC_DEFAULT); | ||
2898 | REG_WRITE(ah, AR_INTR_SYNC_MASK, | ||
2899 | AR_INTR_SYNC_DEFAULT); | ||
2900 | } | ||
2901 | ath_print(common, ATH_DBG_INTERRUPT, "AR_IMR 0x%x IER 0x%x\n", | ||
2902 | REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER)); | ||
2903 | } | ||
2904 | |||
2905 | return omask; | ||
2906 | } | ||
2907 | EXPORT_SYMBOL(ath9k_hw_set_interrupts); | ||
2908 | |||
2909 | /*******************/ | 1845 | /*******************/ |
2910 | /* Beacon Handling */ | 1846 | /* Beacon Handling */ |
2911 | /*******************/ | 1847 | /*******************/ |
@@ -2916,6 +1852,8 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period) | |||
2916 | 1852 | ||
2917 | ah->beacon_interval = beacon_period; | 1853 | ah->beacon_interval = beacon_period; |
2918 | 1854 | ||
1855 | ENABLE_REGWRITE_BUFFER(ah); | ||
1856 | |||
2919 | switch (ah->opmode) { | 1857 | switch (ah->opmode) { |
2920 | case NL80211_IFTYPE_STATION: | 1858 | case NL80211_IFTYPE_STATION: |
2921 | case NL80211_IFTYPE_MONITOR: | 1859 | case NL80211_IFTYPE_MONITOR: |
@@ -2959,6 +1897,9 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period) | |||
2959 | REG_WRITE(ah, AR_SWBA_PERIOD, TU_TO_USEC(beacon_period)); | 1897 | REG_WRITE(ah, AR_SWBA_PERIOD, TU_TO_USEC(beacon_period)); |
2960 | REG_WRITE(ah, AR_NDP_PERIOD, TU_TO_USEC(beacon_period)); | 1898 | REG_WRITE(ah, AR_NDP_PERIOD, TU_TO_USEC(beacon_period)); |
2961 | 1899 | ||
1900 | REGWRITE_BUFFER_FLUSH(ah); | ||
1901 | DISABLE_REGWRITE_BUFFER(ah); | ||
1902 | |||
2962 | beacon_period &= ~ATH9K_BEACON_ENA; | 1903 | beacon_period &= ~ATH9K_BEACON_ENA; |
2963 | if (beacon_period & ATH9K_BEACON_RESET_TSF) { | 1904 | if (beacon_period & ATH9K_BEACON_RESET_TSF) { |
2964 | ath9k_hw_reset_tsf(ah); | 1905 | ath9k_hw_reset_tsf(ah); |
@@ -2975,6 +1916,8 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
2975 | struct ath9k_hw_capabilities *pCap = &ah->caps; | 1916 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
2976 | struct ath_common *common = ath9k_hw_common(ah); | 1917 | struct ath_common *common = ath9k_hw_common(ah); |
2977 | 1918 | ||
1919 | ENABLE_REGWRITE_BUFFER(ah); | ||
1920 | |||
2978 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bs->bs_nexttbtt)); | 1921 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bs->bs_nexttbtt)); |
2979 | 1922 | ||
2980 | REG_WRITE(ah, AR_BEACON_PERIOD, | 1923 | REG_WRITE(ah, AR_BEACON_PERIOD, |
@@ -2982,6 +1925,9 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
2982 | REG_WRITE(ah, AR_DMA_BEACON_PERIOD, | 1925 | REG_WRITE(ah, AR_DMA_BEACON_PERIOD, |
2983 | TU_TO_USEC(bs->bs_intval & ATH9K_BEACON_PERIOD)); | 1926 | TU_TO_USEC(bs->bs_intval & ATH9K_BEACON_PERIOD)); |
2984 | 1927 | ||
1928 | REGWRITE_BUFFER_FLUSH(ah); | ||
1929 | DISABLE_REGWRITE_BUFFER(ah); | ||
1930 | |||
2985 | REG_RMW_FIELD(ah, AR_RSSI_THR, | 1931 | REG_RMW_FIELD(ah, AR_RSSI_THR, |
2986 | AR_RSSI_THR_BM_THR, bs->bs_bmissthreshold); | 1932 | AR_RSSI_THR_BM_THR, bs->bs_bmissthreshold); |
2987 | 1933 | ||
@@ -3004,6 +1950,8 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
3004 | ath_print(common, ATH_DBG_BEACON, "beacon period %d\n", beaconintval); | 1950 | ath_print(common, ATH_DBG_BEACON, "beacon period %d\n", beaconintval); |
3005 | ath_print(common, ATH_DBG_BEACON, "DTIM period %d\n", dtimperiod); | 1951 | ath_print(common, ATH_DBG_BEACON, "DTIM period %d\n", dtimperiod); |
3006 | 1952 | ||
1953 | ENABLE_REGWRITE_BUFFER(ah); | ||
1954 | |||
3007 | REG_WRITE(ah, AR_NEXT_DTIM, | 1955 | REG_WRITE(ah, AR_NEXT_DTIM, |
3008 | TU_TO_USEC(bs->bs_nextdtim - SLEEP_SLOP)); | 1956 | TU_TO_USEC(bs->bs_nextdtim - SLEEP_SLOP)); |
3009 | REG_WRITE(ah, AR_NEXT_TIM, TU_TO_USEC(nextTbtt - SLEEP_SLOP)); | 1957 | REG_WRITE(ah, AR_NEXT_TIM, TU_TO_USEC(nextTbtt - SLEEP_SLOP)); |
@@ -3023,6 +1971,9 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
3023 | REG_WRITE(ah, AR_TIM_PERIOD, TU_TO_USEC(beaconintval)); | 1971 | REG_WRITE(ah, AR_TIM_PERIOD, TU_TO_USEC(beaconintval)); |
3024 | REG_WRITE(ah, AR_DTIM_PERIOD, TU_TO_USEC(dtimperiod)); | 1972 | REG_WRITE(ah, AR_DTIM_PERIOD, TU_TO_USEC(dtimperiod)); |
3025 | 1973 | ||
1974 | REGWRITE_BUFFER_FLUSH(ah); | ||
1975 | DISABLE_REGWRITE_BUFFER(ah); | ||
1976 | |||
3026 | REG_SET_BIT(ah, AR_TIMER_MODE, | 1977 | REG_SET_BIT(ah, AR_TIMER_MODE, |
3027 | AR_TBTT_TIMER_EN | AR_TIM_TIMER_EN | | 1978 | AR_TBTT_TIMER_EN | AR_TIM_TIMER_EN | |
3028 | AR_DTIM_TIMER_EN); | 1979 | AR_DTIM_TIMER_EN); |
@@ -3241,6 +2192,26 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) | |||
3241 | btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE; | 2192 | btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE; |
3242 | } | 2193 | } |
3243 | 2194 | ||
2195 | if (AR_SREV_9300_20_OR_LATER(ah)) { | ||
2196 | pCap->hw_caps |= ATH9K_HW_CAP_EDMA | ATH9K_HW_CAP_LDPC | | ||
2197 | ATH9K_HW_CAP_FASTCLOCK; | ||
2198 | pCap->rx_hp_qdepth = ATH9K_HW_RX_HP_QDEPTH; | ||
2199 | pCap->rx_lp_qdepth = ATH9K_HW_RX_LP_QDEPTH; | ||
2200 | pCap->rx_status_len = sizeof(struct ar9003_rxs); | ||
2201 | pCap->tx_desc_len = sizeof(struct ar9003_txc); | ||
2202 | pCap->txs_len = sizeof(struct ar9003_txs); | ||
2203 | } else { | ||
2204 | pCap->tx_desc_len = sizeof(struct ath_desc); | ||
2205 | if (AR_SREV_9280_20(ah) && | ||
2206 | ((ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) <= | ||
2207 | AR5416_EEP_MINOR_VER_16) || | ||
2208 | ah->eep_ops->get_eeprom(ah, EEP_FSTCLK_5G))) | ||
2209 | pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK; | ||
2210 | } | ||
2211 | |||
2212 | if (AR_SREV_9300_20_OR_LATER(ah)) | ||
2213 | pCap->hw_caps |= ATH9K_HW_CAP_RAC_SUPPORTED; | ||
2214 | |||
3244 | return 0; | 2215 | return 0; |
3245 | } | 2216 | } |
3246 | 2217 | ||
@@ -3273,10 +2244,6 @@ bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type, | |||
3273 | case ATH9K_CAP_TKIP_SPLIT: | 2244 | case ATH9K_CAP_TKIP_SPLIT: |
3274 | return (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) ? | 2245 | return (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) ? |
3275 | false : true; | 2246 | false : true; |
3276 | case ATH9K_CAP_DIVERSITY: | ||
3277 | return (REG_READ(ah, AR_PHY_CCK_DETECT) & | ||
3278 | AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV) ? | ||
3279 | true : false; | ||
3280 | case ATH9K_CAP_MCAST_KEYSRCH: | 2247 | case ATH9K_CAP_MCAST_KEYSRCH: |
3281 | switch (capability) { | 2248 | switch (capability) { |
3282 | case 0: | 2249 | case 0: |
@@ -3319,8 +2286,6 @@ EXPORT_SYMBOL(ath9k_hw_getcapability); | |||
3319 | bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type, | 2286 | bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type, |
3320 | u32 capability, u32 setting, int *status) | 2287 | u32 capability, u32 setting, int *status) |
3321 | { | 2288 | { |
3322 | u32 v; | ||
3323 | |||
3324 | switch (type) { | 2289 | switch (type) { |
3325 | case ATH9K_CAP_TKIP_MIC: | 2290 | case ATH9K_CAP_TKIP_MIC: |
3326 | if (setting) | 2291 | if (setting) |
@@ -3330,14 +2295,6 @@ bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type, | |||
3330 | ah->sta_id1_defaults &= | 2295 | ah->sta_id1_defaults &= |
3331 | ~AR_STA_ID1_CRPT_MIC_ENABLE; | 2296 | ~AR_STA_ID1_CRPT_MIC_ENABLE; |
3332 | return true; | 2297 | return true; |
3333 | case ATH9K_CAP_DIVERSITY: | ||
3334 | v = REG_READ(ah, AR_PHY_CCK_DETECT); | ||
3335 | if (setting) | ||
3336 | v |= AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV; | ||
3337 | else | ||
3338 | v &= ~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV; | ||
3339 | REG_WRITE(ah, AR_PHY_CCK_DETECT, v); | ||
3340 | return true; | ||
3341 | case ATH9K_CAP_MCAST_KEYSRCH: | 2298 | case ATH9K_CAP_MCAST_KEYSRCH: |
3342 | if (setting) | 2299 | if (setting) |
3343 | ah->sta_id1_defaults |= AR_STA_ID1_MCAST_KSRCH; | 2300 | ah->sta_id1_defaults |= AR_STA_ID1_MCAST_KSRCH; |
@@ -3405,7 +2362,9 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio) | |||
3405 | if (gpio >= ah->caps.num_gpio_pins) | 2362 | if (gpio >= ah->caps.num_gpio_pins) |
3406 | return 0xffffffff; | 2363 | return 0xffffffff; |
3407 | 2364 | ||
3408 | if (AR_SREV_9271(ah)) | 2365 | if (AR_SREV_9300_20_OR_LATER(ah)) |
2366 | return MS_REG_READ(AR9300, gpio) != 0; | ||
2367 | else if (AR_SREV_9271(ah)) | ||
3409 | return MS_REG_READ(AR9271, gpio) != 0; | 2368 | return MS_REG_READ(AR9271, gpio) != 0; |
3410 | else if (AR_SREV_9287_10_OR_LATER(ah)) | 2369 | else if (AR_SREV_9287_10_OR_LATER(ah)) |
3411 | return MS_REG_READ(AR9287, gpio) != 0; | 2370 | return MS_REG_READ(AR9287, gpio) != 0; |
@@ -3478,6 +2437,8 @@ void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits) | |||
3478 | { | 2437 | { |
3479 | u32 phybits; | 2438 | u32 phybits; |
3480 | 2439 | ||
2440 | ENABLE_REGWRITE_BUFFER(ah); | ||
2441 | |||
3481 | REG_WRITE(ah, AR_RX_FILTER, bits); | 2442 | REG_WRITE(ah, AR_RX_FILTER, bits); |
3482 | 2443 | ||
3483 | phybits = 0; | 2444 | phybits = 0; |
@@ -3493,6 +2454,9 @@ void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits) | |||
3493 | else | 2454 | else |
3494 | REG_WRITE(ah, AR_RXCFG, | 2455 | REG_WRITE(ah, AR_RXCFG, |
3495 | REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_ZLFDMA); | 2456 | REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_ZLFDMA); |
2457 | |||
2458 | REGWRITE_BUFFER_FLUSH(ah); | ||
2459 | DISABLE_REGWRITE_BUFFER(ah); | ||
3496 | } | 2460 | } |
3497 | EXPORT_SYMBOL(ath9k_hw_setrxfilter); | 2461 | EXPORT_SYMBOL(ath9k_hw_setrxfilter); |
3498 | 2462 | ||
@@ -3565,14 +2529,25 @@ void ath9k_hw_write_associd(struct ath_hw *ah) | |||
3565 | } | 2529 | } |
3566 | EXPORT_SYMBOL(ath9k_hw_write_associd); | 2530 | EXPORT_SYMBOL(ath9k_hw_write_associd); |
3567 | 2531 | ||
2532 | #define ATH9K_MAX_TSF_READ 10 | ||
2533 | |||
3568 | u64 ath9k_hw_gettsf64(struct ath_hw *ah) | 2534 | u64 ath9k_hw_gettsf64(struct ath_hw *ah) |
3569 | { | 2535 | { |
3570 | u64 tsf; | 2536 | u32 tsf_lower, tsf_upper1, tsf_upper2; |
2537 | int i; | ||
2538 | |||
2539 | tsf_upper1 = REG_READ(ah, AR_TSF_U32); | ||
2540 | for (i = 0; i < ATH9K_MAX_TSF_READ; i++) { | ||
2541 | tsf_lower = REG_READ(ah, AR_TSF_L32); | ||
2542 | tsf_upper2 = REG_READ(ah, AR_TSF_U32); | ||
2543 | if (tsf_upper2 == tsf_upper1) | ||
2544 | break; | ||
2545 | tsf_upper1 = tsf_upper2; | ||
2546 | } | ||
3571 | 2547 | ||
3572 | tsf = REG_READ(ah, AR_TSF_U32); | 2548 | WARN_ON( i == ATH9K_MAX_TSF_READ ); |
3573 | tsf = (tsf << 32) | REG_READ(ah, AR_TSF_L32); | ||
3574 | 2549 | ||
3575 | return tsf; | 2550 | return (((u64)tsf_upper1 << 32) | tsf_lower); |
3576 | } | 2551 | } |
3577 | EXPORT_SYMBOL(ath9k_hw_gettsf64); | 2552 | EXPORT_SYMBOL(ath9k_hw_gettsf64); |
3578 | 2553 | ||
@@ -3847,6 +2822,7 @@ static struct { | |||
3847 | { AR_SREV_VERSION_9285, "9285" }, | 2822 | { AR_SREV_VERSION_9285, "9285" }, |
3848 | { AR_SREV_VERSION_9287, "9287" }, | 2823 | { AR_SREV_VERSION_9287, "9287" }, |
3849 | { AR_SREV_VERSION_9271, "9271" }, | 2824 | { AR_SREV_VERSION_9271, "9271" }, |
2825 | { AR_SREV_VERSION_9300, "9300" }, | ||
3850 | }; | 2826 | }; |
3851 | 2827 | ||
3852 | /* For devices with external radios */ | 2828 | /* For devices with external radios */ |