Lines Matching defs:priv

133 static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
137 if (atomic_read(&priv->htc->tgt_ready) > 0) {
138 atomic_dec(&priv->htc->tgt_ready);
143 time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ);
145 dev_err(priv->dev, "ath9k_htc: Target is unresponsive\n");
149 atomic_dec(&priv->htc->tgt_ready);
154 static void ath9k_deinit_priv(struct ath9k_htc_priv *priv)
156 ath9k_hw_deinit(priv->ah);
157 kfree(priv->ah);
158 priv->ah = NULL;
161 static void ath9k_deinit_device(struct ath9k_htc_priv *priv)
163 struct ieee80211_hw *hw = priv->hw;
166 ath9k_deinit_leds(priv);
168 ath9k_rx_cleanup(priv);
169 ath9k_tx_cleanup(priv);
170 ath9k_deinit_priv(priv);
173 static inline int ath9k_htc_connect_svc(struct ath9k_htc_priv *priv,
186 req.ep_callbacks.priv = priv;
190 return htc_connect_service(priv->htc, &req, ep_id);
193 static int ath9k_init_htc_services(struct ath9k_htc_priv *priv, u16 devid,
199 ret = ath9k_wmi_connect(priv->htc, priv->wmi, &priv->wmi_cmd_ep);
204 ret = ath9k_htc_connect_svc(priv, WMI_BEACON_SVC, ath9k_htc_beaconep,
205 &priv->beacon_ep);
210 ret = ath9k_htc_connect_svc(priv, WMI_CAB_SVC, ath9k_htc_txep,
211 &priv->cab_ep);
217 ret = ath9k_htc_connect_svc(priv, WMI_UAPSD_SVC, ath9k_htc_txep,
218 &priv->uapsd_ep);
223 ret = ath9k_htc_connect_svc(priv, WMI_MGMT_SVC, ath9k_htc_txep,
224 &priv->mgmt_ep);
229 ret = ath9k_htc_connect_svc(priv, WMI_DATA_BE_SVC, ath9k_htc_txep,
230 &priv->data_be_ep);
235 ret = ath9k_htc_connect_svc(priv, WMI_DATA_BK_SVC, ath9k_htc_txep,
236 &priv->data_bk_ep);
241 ret = ath9k_htc_connect_svc(priv, WMI_DATA_VI_SVC, ath9k_htc_txep,
242 &priv->data_vi_ep);
247 ret = ath9k_htc_connect_svc(priv, WMI_DATA_VO_SVC, ath9k_htc_txep,
248 &priv->data_vo_ep);
259 priv->htc->credits = 45;
261 priv->htc->credits = 33;
263 ret = htc_init(priv->htc);
267 dev_info(priv->dev, "ath9k_htc: HTC initialized with %d credits\n",
268 priv->htc->credits);
273 dev_err(priv->dev, "ath9k_htc: Unable to initialize HTC services\n");
281 struct ath9k_htc_priv *priv = hw->priv;
284 ath9k_hw_regulatory(priv->ah));
291 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
295 r = ath9k_wmi_cmd(priv->wmi, WMI_REG_READ_CMDID,
313 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
322 ret = ath9k_wmi_cmd(priv->wmi, WMI_REG_READ_CMDID,
340 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
347 r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID,
361 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
365 mutex_lock(&priv->wmi->multi_write_mutex);
368 priv->wmi->multi_write[priv->wmi->multi_write_idx].reg =
370 priv->wmi->multi_write[priv->wmi->multi_write_idx].val =
373 priv->wmi->multi_write_idx++;
376 if (priv->wmi->multi_write_idx == MAX_CMD_NUMBER) {
377 r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID,
378 (u8 *) &priv->wmi->multi_write,
379 sizeof(struct register_write) * priv->wmi->multi_write_idx,
385 priv->wmi->multi_write_idx);
387 priv->wmi->multi_write_idx = 0;
390 mutex_unlock(&priv->wmi->multi_write_mutex);
397 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
399 if (atomic_read(&priv->wmi->mwrite_cnt))
409 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
411 atomic_inc(&priv->wmi->mwrite_cnt);
418 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
422 atomic_dec(&priv->wmi->mwrite_cnt);
424 mutex_lock(&priv->wmi->multi_write_mutex);
426 if (priv->wmi->multi_write_idx) {
427 r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID,
428 (u8 *) &priv->wmi->multi_write,
429 sizeof(struct register_write) * priv->wmi->multi_write_idx,
435 priv->wmi->multi_write_idx);
437 priv->wmi->multi_write_idx = 0;
440 mutex_unlock(&priv->wmi->multi_write_mutex);
484 static void setup_ht_cap(struct ath9k_htc_priv *priv,
487 struct ath_common *common = ath9k_hw_common(priv->ah);
497 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
508 tx_streams = ath9k_cmn_count_streams(priv->ah->txchainmask, 2);
509 rx_streams = ath9k_cmn_count_streams(priv->ah->rxchainmask, 2);
526 static int ath9k_init_queues(struct ath9k_htc_priv *priv)
528 struct ath_common *common = ath9k_hw_common(priv->ah);
531 for (i = 0; i < ARRAY_SIZE(priv->hwq_map); i++)
532 priv->hwq_map[i] = -1;
534 priv->beaconq = ath9k_hw_beaconq_setup(priv->ah);
535 if (priv->beaconq == -1) {
540 priv->cabq = ath9k_htc_cabq_setup(priv);
541 if (priv->cabq == -1) {
546 if (!ath9k_htc_txq_setup(priv, WME_AC_BE)) {
551 if (!ath9k_htc_txq_setup(priv, WME_AC_BK)) {
555 if (!ath9k_htc_txq_setup(priv, WME_AC_VI)) {
559 if (!ath9k_htc_txq_setup(priv, WME_AC_VO)) {
570 static void ath9k_init_channels_rates(struct ath9k_htc_priv *priv)
572 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
573 priv->sbands[IEEE80211_BAND_2GHZ].channels =
575 priv->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
576 priv->sbands[IEEE80211_BAND_2GHZ].n_channels =
578 priv->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
579 priv->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
583 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) {
584 priv->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_channels;
585 priv->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
586 priv->sbands[IEEE80211_BAND_5GHZ].n_channels =
588 priv->sbands[IEEE80211_BAND_5GHZ].bitrates =
590 priv->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
595 static void ath9k_init_misc(struct ath9k_htc_priv *priv)
597 struct ath_common *common = ath9k_hw_common(priv->ah);
601 priv->ah->opmode = NL80211_IFTYPE_STATION;
604 static int ath9k_init_priv(struct ath9k_htc_priv *priv,
612 priv->op_flags |= OP_INVALID;
627 priv->ah = ah;
633 common->hw = priv->hw;
634 common->priv = priv;
637 spin_lock_init(&priv->beacon_lock);
638 spin_lock_init(&priv->tx.tx_lock);
639 mutex_init(&priv->mutex);
640 mutex_init(&priv->htc_pm_lock);
641 tasklet_init(&priv->rx_tasklet, ath9k_rx_tasklet,
642 (unsigned long)priv);
643 tasklet_init(&priv->tx_failed_tasklet, ath9k_tx_failed_tasklet,
644 (unsigned long)priv);
645 INIT_DELAYED_WORK(&priv->ani_work, ath9k_htc_ani_work);
646 INIT_WORK(&priv->ps_work, ath9k_ps_work);
647 INIT_WORK(&priv->fatal_work, ath9k_fatal_work);
648 setup_timer(&priv->tx.cleanup_timer, ath9k_htc_tx_cleanup_timer,
649 (unsigned long)priv);
666 ret = ath9k_init_queues(priv);
671 priv->cur_beacon_conf.bslot[i] = NULL;
674 ath9k_init_channels_rates(priv);
675 ath9k_init_misc(priv);
676 ath9k_htc_init_btcoex(priv, product);
685 priv->ah = NULL;
690 static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
693 struct ath_common *common = ath9k_hw_common(priv->ah);
727 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
729 &priv->sbands[IEEE80211_BAND_2GHZ];
730 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
732 &priv->sbands[IEEE80211_BAND_5GHZ];
734 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
735 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
736 setup_ht_cap(priv,
737 &priv->sbands[IEEE80211_BAND_2GHZ].ht_cap);
738 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
739 setup_ht_cap(priv,
740 &priv->sbands[IEEE80211_BAND_5GHZ].ht_cap);
746 static int ath9k_init_firmware_version(struct ath9k_htc_priv *priv)
748 struct ieee80211_hw *hw = priv->hw;
758 priv->fw_version_major = be16_to_cpu(cmd_rsp.major);
759 priv->fw_version_minor = be16_to_cpu(cmd_rsp.minor);
762 priv->fw_version_major,
763 priv->fw_version_minor);
765 dev_info(priv->dev, "ath9k_htc: FW Version: %d.%d\n",
766 priv->fw_version_major,
767 priv->fw_version_minor);
773 if (priv->fw_version_major != MAJOR_VERSION_REQ ||
774 priv->fw_version_minor != MINOR_VERSION_REQ) {
775 dev_err(priv->dev, "ath9k_htc: Please upgrade to FW version %d.%d\n",
783 static int ath9k_init_device(struct ath9k_htc_priv *priv,
786 struct ieee80211_hw *hw = priv->hw;
794 error = ath9k_init_priv(priv, devid, product, drv_info);
798 ah = priv->ah;
800 ath9k_set_hw_capab(priv, hw);
802 error = ath9k_init_firmware_version(priv);
807 error = ath_regd_init(&common->regulatory, priv->hw->wiphy,
815 error = ath9k_tx_init(priv);
820 error = ath9k_rx_init(priv);
826 priv->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(priv->hw,
843 error = ath9k_htc_init_debug(priv->ah);
851 priv->wmi_cmd_ep,
852 priv->beacon_ep,
853 priv->cab_ep,
854 priv->uapsd_ep,
855 priv->mgmt_ep,
856 priv->data_be_ep,
857 priv->data_bk_ep,
858 priv->data_vi_ep,
859 priv->data_vo_ep);
861 ath9k_hw_name(priv->ah, hw_name, sizeof(hw_name));
864 ath9k_init_leds(priv);
865 ath9k_start_rfkill_poll(priv);
872 ath9k_rx_cleanup(priv);
874 ath9k_tx_cleanup(priv);
880 ath9k_deinit_priv(priv);
889 struct ath9k_htc_priv *priv;
896 priv = hw->priv;
897 priv->hw = hw;
898 priv->htc = htc_handle;
899 priv->dev = dev;
900 htc_handle->drv_priv = priv;
901 SET_IEEE80211_DEV(hw, priv->dev);
903 ret = ath9k_htc_wait_for_target(priv);
907 priv->wmi = ath9k_init_wmi(priv);
908 if (!priv->wmi) {
913 ret = ath9k_init_htc_services(priv, devid, drv_info);
917 ret = ath9k_init_device(priv, devid, product, drv_info);
924 ath9k_deinit_wmi(priv);
953 struct ath9k_htc_priv *priv = htc_handle->drv_priv;
956 ret = ath9k_htc_wait_for_target(priv);
960 ret = ath9k_init_htc_services(priv, priv->ah->hw_version.devid,
961 priv->ah->hw_version.usbdev);