Lines Matching refs:sc

93 static void ath9k_deinit_softc(struct ath_softc *sc);
120 struct ath_softc *sc = (struct ath_softc *) common->priv; in ath9k_iowrite32() local
124 spin_lock_irqsave(&sc->sc_serial_rw, flags); in ath9k_iowrite32()
125 iowrite32(val, sc->mem + reg_offset); in ath9k_iowrite32()
126 spin_unlock_irqrestore(&sc->sc_serial_rw, flags); in ath9k_iowrite32()
128 iowrite32(val, sc->mem + reg_offset); in ath9k_iowrite32()
135 struct ath_softc *sc = (struct ath_softc *) common->priv; in ath9k_ioread32() local
140 spin_lock_irqsave(&sc->sc_serial_rw, flags); in ath9k_ioread32()
141 val = ioread32(sc->mem + reg_offset); in ath9k_ioread32()
142 spin_unlock_irqrestore(&sc->sc_serial_rw, flags); in ath9k_ioread32()
144 val = ioread32(sc->mem + reg_offset); in ath9k_ioread32()
158 static unsigned int __ath9k_reg_rmw(struct ath_softc *sc, u32 reg_offset, in __ath9k_reg_rmw() argument
163 val = ioread32(sc->mem + reg_offset); in __ath9k_reg_rmw()
166 iowrite32(val, sc->mem + reg_offset); in __ath9k_reg_rmw()
175 struct ath_softc *sc = (struct ath_softc *) common->priv; in ath9k_reg_rmw() local
180 spin_lock_irqsave(&sc->sc_serial_rw, flags); in ath9k_reg_rmw()
181 val = __ath9k_reg_rmw(sc, reg_offset, set, clr); in ath9k_reg_rmw()
182 spin_unlock_irqrestore(&sc->sc_serial_rw, flags); in ath9k_reg_rmw()
184 val = __ath9k_reg_rmw(sc, reg_offset, set, clr); in ath9k_reg_rmw()
197 struct ath_softc *sc = hw->priv; in ath9k_reg_notifier() local
198 struct ath_hw *ah = sc->sc_ah; in ath9k_reg_notifier()
207 sc->cur_chan->txpower = 2 * ah->curchan->chan->max_power; in ath9k_reg_notifier()
208 ath9k_ps_wakeup(sc); in ath9k_reg_notifier()
209 ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false); in ath9k_reg_notifier()
210 ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower, in ath9k_reg_notifier()
211 sc->cur_chan->txpower, in ath9k_reg_notifier()
212 &sc->cur_chan->cur_txpower); in ath9k_reg_notifier()
214 if (sc->dfs_detector != NULL) in ath9k_reg_notifier()
215 sc->dfs_detector->set_dfs_domain(sc->dfs_detector, in ath9k_reg_notifier()
217 ath9k_ps_restore(sc); in ath9k_reg_notifier()
225 int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, in ath_descdma_setup() argument
229 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_descdma_setup()
239 desc_len = sc->sc_ah->caps.tx_desc_len; in ath_descdma_setup()
257 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) { in ath_descdma_setup()
271 dd->dd_desc = dmam_alloc_coherent(sc->dev, dd->dd_desc_len, in ath_descdma_setup()
286 bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); in ath_descdma_setup()
294 if (!(sc->sc_ah->caps.hw_caps & in ath_descdma_setup()
317 bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); in ath_descdma_setup()
325 if (!(sc->sc_ah->caps.hw_caps & in ath_descdma_setup()
348 static int ath9k_init_queues(struct ath_softc *sc) in ath9k_init_queues() argument
352 sc->beacon.beaconq = ath9k_hw_beaconq_setup(sc->sc_ah); in ath9k_init_queues()
353 sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0); in ath9k_init_queues()
354 ath_cabq_update(sc); in ath9k_init_queues()
356 sc->tx.uapsdq = ath_txq_setup(sc, ATH9K_TX_QUEUE_UAPSD, 0); in ath9k_init_queues()
359 sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i); in ath9k_init_queues()
360 sc->tx.txq_map[i]->mac80211_qnum = i; in ath9k_init_queues()
361 sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH; in ath9k_init_queues()
366 static void ath9k_init_misc(struct ath_softc *sc) in ath9k_init_misc() argument
368 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_init_misc()
371 setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc); in ath9k_init_misc()
375 sc->beacon.slottime = ATH9K_SLOT_TIME_9; in ath9k_init_misc()
377 for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) in ath9k_init_misc()
378 sc->beacon.bslot[i] = NULL; in ath9k_init_misc()
380 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) in ath9k_init_misc()
381 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; in ath9k_init_misc()
383 sc->spec_priv.ah = sc->sc_ah; in ath9k_init_misc()
384 sc->spec_priv.spec_config.enabled = 0; in ath9k_init_misc()
385 sc->spec_priv.spec_config.short_repeat = true; in ath9k_init_misc()
386 sc->spec_priv.spec_config.count = 8; in ath9k_init_misc()
387 sc->spec_priv.spec_config.endless = false; in ath9k_init_misc()
388 sc->spec_priv.spec_config.period = 0xFF; in ath9k_init_misc()
389 sc->spec_priv.spec_config.fft_period = 0xF; in ath9k_init_misc()
392 static void ath9k_init_pcoem_platform(struct ath_softc *sc) in ath9k_init_pcoem_platform() argument
394 struct ath_hw *ah = sc->sc_ah; in ath9k_init_pcoem_platform()
404 if (sc->driver_data & (ATH9K_PCI_CUS198 | in ath9k_init_pcoem_platform()
410 sc->ant_comb.low_rssi_thresh = 20; in ath9k_init_pcoem_platform()
411 sc->ant_comb.fast_div_bias = 3; in ath9k_init_pcoem_platform()
414 (sc->driver_data & ATH9K_PCI_CUS198) ? in ath9k_init_pcoem_platform()
418 if (sc->driver_data & ATH9K_PCI_CUS217) in ath9k_init_pcoem_platform()
421 if (sc->driver_data & ATH9K_PCI_CUS252) in ath9k_init_pcoem_platform()
424 if (sc->driver_data & ATH9K_PCI_AR9565_1ANT) in ath9k_init_pcoem_platform()
427 if (sc->driver_data & ATH9K_PCI_AR9565_2ANT) in ath9k_init_pcoem_platform()
430 if (sc->driver_data & ATH9K_PCI_KILLER) in ath9k_init_pcoem_platform()
439 if (sc->driver_data & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { in ath9k_init_pcoem_platform()
440 if (!(sc->driver_data & ATH9K_PCI_BT_ANT_DIV)) in ath9k_init_pcoem_platform()
444 if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) { in ath9k_init_pcoem_platform()
449 if (sc->driver_data & ATH9K_PCI_D3_L1_WAR) { in ath9k_init_pcoem_platform()
461 if (sc->driver_data & ATH9K_PCI_NO_PLL_PWRSAVE) { in ath9k_init_pcoem_platform()
466 if (sc->driver_data & ATH9K_PCI_LED_ACT_HI) in ath9k_init_pcoem_platform()
481 static int ath9k_eeprom_request(struct ath_softc *sc, const char *name) in ath9k_eeprom_request() argument
484 struct ath_hw *ah = ah = sc->sc_ah; in ath9k_eeprom_request()
489 ec.ah = sc->sc_ah; in ath9k_eeprom_request()
491 err = request_firmware_nowait(THIS_MODULE, 1, name, sc->dev, GFP_KERNEL, in ath9k_eeprom_request()
510 static void ath9k_eeprom_release(struct ath_softc *sc) in ath9k_eeprom_release() argument
512 release_firmware(sc->sc_ah->eeprom_blob); in ath9k_eeprom_release()
515 static int ath9k_init_soc_platform(struct ath_softc *sc) in ath9k_init_soc_platform() argument
517 struct ath9k_platform_data *pdata = sc->dev->platform_data; in ath9k_init_soc_platform()
518 struct ath_hw *ah = sc->sc_ah; in ath9k_init_soc_platform()
525 ret = ath9k_eeprom_request(sc, pdata->eeprom_name); in ath9k_init_soc_platform()
536 static int ath9k_init_softc(u16 devid, struct ath_softc *sc, in ath9k_init_softc() argument
539 struct ath9k_platform_data *pdata = sc->dev->platform_data; in ath9k_init_softc()
546 ah = devm_kzalloc(sc->dev, sizeof(struct ath_hw), GFP_KERNEL); in ath9k_init_softc()
550 ah->dev = sc->dev; in ath9k_init_softc()
551 ah->hw = sc->hw; in ath9k_init_softc()
564 sc->sc_ah = ah; in ath9k_init_softc()
565 sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET); in ath9k_init_softc()
566 sc->tx99_power = MAX_RATE_POWER + 1; in ath9k_init_softc()
567 init_waitqueue_head(&sc->tx_wait); in ath9k_init_softc()
568 sc->cur_chan = &sc->chanctx[0]; in ath9k_init_softc()
570 sc->cur_chan->hw_queue_base = 0; in ath9k_init_softc()
574 sc->sc_ah->led_pin = -1; in ath9k_init_softc()
576 sc->sc_ah->gpio_mask = pdata->gpio_mask; in ath9k_init_softc()
577 sc->sc_ah->gpio_val = pdata->gpio_val; in ath9k_init_softc()
578 sc->sc_ah->led_pin = pdata->led_pin; in ath9k_init_softc()
592 common->hw = sc->hw; in ath9k_init_softc()
593 common->priv = sc; in ath9k_init_softc()
601 ath9k_init_pcoem_platform(sc); in ath9k_init_softc()
603 ret = ath9k_init_soc_platform(sc); in ath9k_init_softc()
622 spin_lock_init(&sc->sc_serial_rw); in ath9k_init_softc()
623 spin_lock_init(&sc->sc_pm_lock); in ath9k_init_softc()
624 spin_lock_init(&sc->chan_lock); in ath9k_init_softc()
625 mutex_init(&sc->mutex); in ath9k_init_softc()
626 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); in ath9k_init_softc()
627 tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet, in ath9k_init_softc()
628 (unsigned long)sc); in ath9k_init_softc()
630 setup_timer(&sc->sleep_timer, ath_ps_full_sleep, (unsigned long)sc); in ath9k_init_softc()
631 INIT_WORK(&sc->hw_reset_work, ath_reset_work); in ath9k_init_softc()
632 INIT_WORK(&sc->paprd_work, ath_paprd_calibrate); in ath9k_init_softc()
633 INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work); in ath9k_init_softc()
635 ath9k_init_channel_context(sc); in ath9k_init_softc()
652 ret = ath9k_init_queues(sc); in ath9k_init_softc()
656 ret = ath9k_init_btcoex(sc); in ath9k_init_softc()
664 ret = ath9k_init_p2p(sc); in ath9k_init_softc()
668 ath9k_cmn_init_crypto(sc->sc_ah); in ath9k_init_softc()
669 ath9k_init_misc(sc); in ath9k_init_softc()
670 ath_fill_led_pin(sc); in ath9k_init_softc()
671 ath_chanctx_init(sc); in ath9k_init_softc()
672 ath9k_offchannel_init(sc); in ath9k_init_softc()
681 if (ATH_TXQ_SETUP(sc, i)) in ath9k_init_softc()
682 ath_tx_cleanupq(sc, &sc->tx.txq[i]); in ath9k_init_softc()
686 ath9k_eeprom_release(sc); in ath9k_init_softc()
687 dev_kfree_skb_any(sc->tx99_skb); in ath9k_init_softc()
691 static void ath9k_init_band_txpower(struct ath_softc *sc, int band) in ath9k_init_band_txpower() argument
695 struct ath_hw *ah = sc->sc_ah; in ath9k_init_band_txpower()
705 ath9k_cmn_get_channel(sc->hw, ah, &chandef); in ath9k_init_band_txpower()
710 static void ath9k_init_txpower_limits(struct ath_softc *sc) in ath9k_init_txpower_limits() argument
712 struct ath_hw *ah = sc->sc_ah; in ath9k_init_txpower_limits()
716 ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ); in ath9k_init_txpower_limits()
718 ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ); in ath9k_init_txpower_limits()
799 static void ath9k_set_mcc_capab(struct ath_softc *sc, struct ieee80211_hw *hw) in ath9k_set_mcc_capab() argument
801 struct ath_hw *ah = sc->sc_ah; in ath9k_set_mcc_capab()
824 static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) in ath9k_set_hw_capab() argument
826 struct ath_hw *ah = sc->sc_ah; in ath9k_set_hw_capab()
842 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { in ath9k_set_hw_capab()
850 if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || ath9k_modparam_nohwcrypt) in ath9k_set_hw_capab()
900 sc->ant_rx = hw->wiphy->available_antennas_rx; in ath9k_set_hw_capab()
901 sc->ant_tx = hw->wiphy->available_antennas_tx; in ath9k_set_hw_capab()
903 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) in ath9k_set_hw_capab()
906 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) in ath9k_set_hw_capab()
911 ath9k_set_mcc_capab(sc, hw); in ath9k_set_hw_capab()
919 int ath9k_init_device(u16 devid, struct ath_softc *sc, in ath9k_init_device() argument
922 struct ieee80211_hw *hw = sc->hw; in ath9k_init_device()
929 error = ath9k_init_softc(devid, sc, bus_ops); in ath9k_init_device()
933 ah = sc->sc_ah; in ath9k_init_device()
935 ath9k_set_hw_capab(sc, hw); in ath9k_init_device()
938 error = ath_regd_init(&common->regulatory, sc->hw->wiphy, in ath9k_init_device()
946 error = ath_tx_init(sc, ATH_TXBUF); in ath9k_init_device()
951 error = ath_rx_init(sc, ATH_RXBUF); in ath9k_init_device()
955 ath9k_init_txpower_limits(sc); in ath9k_init_device()
959 sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw, in ath9k_init_device()
982 ath_init_leds(sc); in ath9k_init_device()
983 ath_start_rfkill_poll(sc); in ath9k_init_device()
988 ath9k_deinit_debug(sc); in ath9k_init_device()
992 ath_rx_cleanup(sc); in ath9k_init_device()
994 ath9k_deinit_softc(sc); in ath9k_init_device()
1002 static void ath9k_deinit_softc(struct ath_softc *sc) in ath9k_deinit_softc() argument
1006 ath9k_deinit_p2p(sc); in ath9k_deinit_softc()
1007 ath9k_deinit_btcoex(sc); in ath9k_deinit_softc()
1010 if (ATH_TXQ_SETUP(sc, i)) in ath9k_deinit_softc()
1011 ath_tx_cleanupq(sc, &sc->tx.txq[i]); in ath9k_deinit_softc()
1013 del_timer_sync(&sc->sleep_timer); in ath9k_deinit_softc()
1014 ath9k_hw_deinit(sc->sc_ah); in ath9k_deinit_softc()
1015 if (sc->dfs_detector != NULL) in ath9k_deinit_softc()
1016 sc->dfs_detector->exit(sc->dfs_detector); in ath9k_deinit_softc()
1018 ath9k_eeprom_release(sc); in ath9k_deinit_softc()
1021 void ath9k_deinit_device(struct ath_softc *sc) in ath9k_deinit_device() argument
1023 struct ieee80211_hw *hw = sc->hw; in ath9k_deinit_device()
1025 ath9k_ps_wakeup(sc); in ath9k_deinit_device()
1027 wiphy_rfkill_stop_polling(sc->hw->wiphy); in ath9k_deinit_device()
1028 ath_deinit_leds(sc); in ath9k_deinit_device()
1030 ath9k_ps_restore(sc); in ath9k_deinit_device()
1032 ath9k_deinit_debug(sc); in ath9k_deinit_device()
1035 ath_rx_cleanup(sc); in ath9k_deinit_device()
1036 ath9k_deinit_softc(sc); in ath9k_deinit_device()