diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/init.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/init.c | 82 |
1 files changed, 35 insertions, 47 deletions
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index aa0ff7e2c922..d4c909f8e474 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/ath9k_platform.h> | 19 | #include <linux/ath9k_platform.h> |
20 | #include <linux/module.h> | ||
20 | 21 | ||
21 | #include "ath9k.h" | 22 | #include "ath9k.h" |
22 | 23 | ||
@@ -270,8 +271,8 @@ static void setup_ht_cap(struct ath_softc *sc, | |||
270 | 271 | ||
271 | /* set up supported mcs set */ | 272 | /* set up supported mcs set */ |
272 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); | 273 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
273 | tx_streams = ath9k_cmn_count_streams(common->tx_chainmask, max_streams); | 274 | tx_streams = ath9k_cmn_count_streams(ah->txchainmask, max_streams); |
274 | rx_streams = ath9k_cmn_count_streams(common->rx_chainmask, max_streams); | 275 | rx_streams = ath9k_cmn_count_streams(ah->rxchainmask, max_streams); |
275 | 276 | ||
276 | ath_dbg(common, ATH_DBG_CONFIG, | 277 | ath_dbg(common, ATH_DBG_CONFIG, |
277 | "TX streams %d, RX streams: %d\n", | 278 | "TX streams %d, RX streams: %d\n", |
@@ -404,31 +405,6 @@ fail: | |||
404 | return error; | 405 | return error; |
405 | } | 406 | } |
406 | 407 | ||
407 | void ath9k_init_crypto(struct ath_softc *sc) | ||
408 | { | ||
409 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
410 | int i = 0; | ||
411 | |||
412 | /* Get the hardware key cache size. */ | ||
413 | common->keymax = AR_KEYTABLE_SIZE; | ||
414 | |||
415 | /* | ||
416 | * Reset the key cache since some parts do not | ||
417 | * reset the contents on initial power up. | ||
418 | */ | ||
419 | for (i = 0; i < common->keymax; i++) | ||
420 | ath_hw_keyreset(common, (u16) i); | ||
421 | |||
422 | /* | ||
423 | * Check whether the separate key cache entries | ||
424 | * are required to handle both tx+rx MIC keys. | ||
425 | * With split mic keys the number of stations is limited | ||
426 | * to 27 otherwise 59. | ||
427 | */ | ||
428 | if (sc->sc_ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) | ||
429 | common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED; | ||
430 | } | ||
431 | |||
432 | static int ath9k_init_btcoex(struct ath_softc *sc) | 408 | static int ath9k_init_btcoex(struct ath_softc *sc) |
433 | { | 409 | { |
434 | struct ath_txq *txq; | 410 | struct ath_txq *txq; |
@@ -531,10 +507,6 @@ static void ath9k_init_misc(struct ath_softc *sc) | |||
531 | sc->sc_flags |= SC_OP_RXAGGR; | 507 | sc->sc_flags |= SC_OP_RXAGGR; |
532 | } | 508 | } |
533 | 509 | ||
534 | common->tx_chainmask = sc->sc_ah->caps.tx_chainmask; | ||
535 | common->rx_chainmask = sc->sc_ah->caps.rx_chainmask; | ||
536 | |||
537 | ath9k_hw_set_diversity(sc->sc_ah, true); | ||
538 | sc->rx.defant = ath9k_hw_getdefantenna(sc->sc_ah); | 510 | sc->rx.defant = ath9k_hw_getdefantenna(sc->sc_ah); |
539 | 511 | ||
540 | memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); | 512 | memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); |
@@ -548,7 +520,7 @@ static void ath9k_init_misc(struct ath_softc *sc) | |||
548 | sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; | 520 | sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; |
549 | } | 521 | } |
550 | 522 | ||
551 | static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, | 523 | static int ath9k_init_softc(u16 devid, struct ath_softc *sc, |
552 | const struct ath_bus_ops *bus_ops) | 524 | const struct ath_bus_ops *bus_ops) |
553 | { | 525 | { |
554 | struct ath9k_platform_data *pdata = sc->dev->platform_data; | 526 | struct ath9k_platform_data *pdata = sc->dev->platform_data; |
@@ -563,10 +535,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
563 | 535 | ||
564 | ah->hw = sc->hw; | 536 | ah->hw = sc->hw; |
565 | ah->hw_version.devid = devid; | 537 | ah->hw_version.devid = devid; |
566 | ah->hw_version.subsysid = subsysid; | ||
567 | ah->reg_ops.read = ath9k_ioread32; | 538 | ah->reg_ops.read = ath9k_ioread32; |
568 | ah->reg_ops.write = ath9k_iowrite32; | 539 | ah->reg_ops.write = ath9k_iowrite32; |
569 | ah->reg_ops.rmw = ath9k_reg_rmw; | 540 | ah->reg_ops.rmw = ath9k_reg_rmw; |
541 | atomic_set(&ah->intr_ref_cnt, -1); | ||
570 | sc->sc_ah = ah; | 542 | sc->sc_ah = ah; |
571 | 543 | ||
572 | if (!pdata) { | 544 | if (!pdata) { |
@@ -597,6 +569,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
597 | mutex_init(&sc->mutex); | 569 | mutex_init(&sc->mutex); |
598 | #ifdef CONFIG_ATH9K_DEBUGFS | 570 | #ifdef CONFIG_ATH9K_DEBUGFS |
599 | spin_lock_init(&sc->nodes_lock); | 571 | spin_lock_init(&sc->nodes_lock); |
572 | spin_lock_init(&sc->debug.samp_lock); | ||
600 | INIT_LIST_HEAD(&sc->nodes); | 573 | INIT_LIST_HEAD(&sc->nodes); |
601 | #endif | 574 | #endif |
602 | tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); | 575 | tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); |
@@ -630,7 +603,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
630 | if (ret) | 603 | if (ret) |
631 | goto err_btcoex; | 604 | goto err_btcoex; |
632 | 605 | ||
633 | ath9k_init_crypto(sc); | 606 | ath9k_cmn_init_crypto(sc->sc_ah); |
634 | ath9k_init_misc(sc); | 607 | ath9k_init_misc(sc); |
635 | 608 | ||
636 | return 0; | 609 | return 0; |
@@ -654,7 +627,6 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band) | |||
654 | struct ieee80211_supported_band *sband; | 627 | struct ieee80211_supported_band *sband; |
655 | struct ieee80211_channel *chan; | 628 | struct ieee80211_channel *chan; |
656 | struct ath_hw *ah = sc->sc_ah; | 629 | struct ath_hw *ah = sc->sc_ah; |
657 | struct ath_regulatory *reg = ath9k_hw_regulatory(ah); | ||
658 | int i; | 630 | int i; |
659 | 631 | ||
660 | sband = &sc->sbands[band]; | 632 | sband = &sc->sbands[band]; |
@@ -663,17 +635,14 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band) | |||
663 | ah->curchan = &ah->channels[chan->hw_value]; | 635 | ah->curchan = &ah->channels[chan->hw_value]; |
664 | ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20); | 636 | ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20); |
665 | ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); | 637 | ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); |
666 | chan->max_power = reg->max_power_level / 2; | ||
667 | } | 638 | } |
668 | } | 639 | } |
669 | 640 | ||
670 | static void ath9k_init_txpower_limits(struct ath_softc *sc) | 641 | static void ath9k_init_txpower_limits(struct ath_softc *sc) |
671 | { | 642 | { |
672 | struct ath_hw *ah = sc->sc_ah; | 643 | struct ath_hw *ah = sc->sc_ah; |
673 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
674 | struct ath9k_channel *curchan = ah->curchan; | 644 | struct ath9k_channel *curchan = ah->curchan; |
675 | 645 | ||
676 | ah->txchainmask = common->tx_chainmask; | ||
677 | if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) | 646 | if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) |
678 | ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ); | 647 | ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ); |
679 | if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) | 648 | if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) |
@@ -682,9 +651,22 @@ static void ath9k_init_txpower_limits(struct ath_softc *sc) | |||
682 | ah->curchan = curchan; | 651 | ah->curchan = curchan; |
683 | } | 652 | } |
684 | 653 | ||
654 | void ath9k_reload_chainmask_settings(struct ath_softc *sc) | ||
655 | { | ||
656 | if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)) | ||
657 | return; | ||
658 | |||
659 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) | ||
660 | setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap); | ||
661 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) | ||
662 | setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap); | ||
663 | } | ||
664 | |||
665 | |||
685 | void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | 666 | void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) |
686 | { | 667 | { |
687 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 668 | struct ath_hw *ah = sc->sc_ah; |
669 | struct ath_common *common = ath9k_hw_common(ah); | ||
688 | 670 | ||
689 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | | 671 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | |
690 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | 672 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
@@ -722,6 +704,16 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
722 | hw->sta_data_size = sizeof(struct ath_node); | 704 | hw->sta_data_size = sizeof(struct ath_node); |
723 | hw->vif_data_size = sizeof(struct ath_vif); | 705 | hw->vif_data_size = sizeof(struct ath_vif); |
724 | 706 | ||
707 | hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; | ||
708 | hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1; | ||
709 | |||
710 | /* single chain devices with rx diversity */ | ||
711 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) | ||
712 | hw->wiphy->available_antennas_rx = BIT(0) | BIT(1); | ||
713 | |||
714 | sc->ant_rx = hw->wiphy->available_antennas_rx; | ||
715 | sc->ant_tx = hw->wiphy->available_antennas_tx; | ||
716 | |||
725 | #ifdef CONFIG_ATH9K_RATE_CONTROL | 717 | #ifdef CONFIG_ATH9K_RATE_CONTROL |
726 | hw->rate_control_algorithm = "ath9k_rate_control"; | 718 | hw->rate_control_algorithm = "ath9k_rate_control"; |
727 | #endif | 719 | #endif |
@@ -733,17 +725,12 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
733 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | 725 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
734 | &sc->sbands[IEEE80211_BAND_5GHZ]; | 726 | &sc->sbands[IEEE80211_BAND_5GHZ]; |
735 | 727 | ||
736 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { | 728 | ath9k_reload_chainmask_settings(sc); |
737 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) | ||
738 | setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap); | ||
739 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) | ||
740 | setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap); | ||
741 | } | ||
742 | 729 | ||
743 | SET_IEEE80211_PERM_ADDR(hw, common->macaddr); | 730 | SET_IEEE80211_PERM_ADDR(hw, common->macaddr); |
744 | } | 731 | } |
745 | 732 | ||
746 | int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid, | 733 | int ath9k_init_device(u16 devid, struct ath_softc *sc, |
747 | const struct ath_bus_ops *bus_ops) | 734 | const struct ath_bus_ops *bus_ops) |
748 | { | 735 | { |
749 | struct ieee80211_hw *hw = sc->hw; | 736 | struct ieee80211_hw *hw = sc->hw; |
@@ -753,7 +740,7 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
753 | struct ath_regulatory *reg; | 740 | struct ath_regulatory *reg; |
754 | 741 | ||
755 | /* Bring up device */ | 742 | /* Bring up device */ |
756 | error = ath9k_init_softc(devid, sc, subsysid, bus_ops); | 743 | error = ath9k_init_softc(devid, sc, bus_ops); |
757 | if (error != 0) | 744 | if (error != 0) |
758 | goto error_init; | 745 | goto error_init; |
759 | 746 | ||
@@ -806,6 +793,7 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
806 | goto error_world; | 793 | goto error_world; |
807 | } | 794 | } |
808 | 795 | ||
796 | INIT_WORK(&sc->hw_reset_work, ath_reset_work); | ||
809 | INIT_WORK(&sc->hw_check_work, ath_hw_check); | 797 | INIT_WORK(&sc->hw_check_work, ath_hw_check); |
810 | INIT_WORK(&sc->paprd_work, ath_paprd_calibrate); | 798 | INIT_WORK(&sc->paprd_work, ath_paprd_calibrate); |
811 | INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work); | 799 | INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work); |