Lines Matching +full:mt7986 +full:- +full:wed
1 // SPDX-License-Identifier: ISC
6 #include <linux/hwmon-sysfs.h>
51 int i = to_sensor_dev_attr(attr)->index;
56 mutex_lock(&phy->dev->mt76.mutex);
58 mutex_unlock(&phy->dev->mt76.mutex);
66 phy->throttle_temp[i - 1] * 1000);
68 return sprintf(buf, "%hhu\n", phy->throttle_state);
70 return -EINVAL;
79 int ret, i = to_sensor_dev_attr(attr)->index;
86 mutex_lock(&phy->dev->mt76.mutex);
89 if ((i - 1 == MT7915_CRIT_TEMP_IDX &&
90 val > phy->throttle_temp[MT7915_MAX_TEMP_IDX]) ||
91 (i - 1 == MT7915_MAX_TEMP_IDX &&
92 val < phy->throttle_temp[MT7915_CRIT_TEMP_IDX])) {
93 dev_err(phy->dev->mt76.dev,
95 mutex_unlock(&phy->dev->mt76.mutex);
96 return -EINVAL;
99 phy->throttle_temp[i - 1] = val;
101 mutex_unlock(&phy->dev->mt76.mutex);
135 struct mt7915_phy *phy = cdev->devdata;
137 *state = phy->cdev_state;
146 struct mt7915_phy *phy = cdev->devdata;
147 u8 throttling = MT7915_THERMAL_THROTTLE_MAX - state;
151 dev_err(phy->dev->mt76.dev,
153 return -EINVAL;
156 if (state == phy->cdev_state)
163 mutex_lock(&phy->dev->mt76.mutex);
165 mutex_unlock(&phy->dev->mt76.mutex);
169 phy->cdev_state = state;
182 struct wiphy *wiphy = phy->mt76->hw->wiphy;
184 if (!phy->cdev)
187 sysfs_remove_link(&wiphy->dev.kobj, "cooling_device");
188 thermal_cooling_device_unregister(phy->cdev);
193 struct wiphy *wiphy = phy->mt76->hw->wiphy;
198 name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7915_%s",
201 return -ENOMEM;
205 if (sysfs_create_link(&wiphy->dev.kobj, &cdev->device.kobj,
209 phy->cdev = cdev;
213 phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = MT7915_CRIT_TEMP;
214 phy->throttle_temp[MT7915_MAX_TEMP_IDX] = MT7915_MAX_TEMP;
219 hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, phy,
232 dev = container_of(mphy->dev, struct mt7915_dev, mt76);
238 mt76_wr(dev, MT_LED_STATUS_0(mphy->band_idx), val);
239 mt76_wr(dev, MT_LED_STATUS_1(mphy->band_idx), val);
242 mt76_wr(dev, MT_LED_EN(mphy->band_idx), 1);
246 if (dev->mphy.leds.al)
248 if (mphy->band_idx)
251 mt76_wr(dev, MT_LED_CTRL(mphy->band_idx), val);
252 mt76_clear(dev, MT_LED_CTRL(mphy->band_idx), MT_LED_CTRL_KICK);
286 struct mt7915_dev *dev = phy->dev;
287 int i, n_chains = hweight16(phy->mt76->chainmask);
289 int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band);
292 for (i = 0; i < sband->n_channels; i++) {
293 struct ieee80211_channel *chan = &sband->channels[i];
305 target_power = mt76_get_rate_power_limits(phy->mt76, chan,
310 chan->max_power = min_t(int, chan->max_reg_power,
312 chan->orig_mpwr = target_power;
321 if (phy->mt76->cap.has_2ghz)
322 __mt7915_init_txpower(phy, &phy->mt76->sband_2g.sband);
323 if (phy->mt76->cap.has_5ghz)
324 __mt7915_init_txpower(phy, &phy->mt76->sband_5g.sband);
325 if (phy->mt76->cap.has_6ghz)
326 __mt7915_init_txpower(phy, &phy->mt76->sband_6g.sband);
335 struct mt76_phy *mphy = hw->priv;
336 struct mt7915_phy *phy = mphy->priv;
338 memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2));
339 dev->mt76.region = request->dfs_region;
341 if (dev->mt76.region == NL80211_DFS_UNSET)
346 mphy->dfs_state = MT_DFS_STATE_UNKNOWN;
353 struct mt76_phy *mphy = phy->mt76;
354 struct ieee80211_hw *hw = mphy->hw;
355 struct mt76_dev *mdev = &phy->dev->mt76;
356 struct wiphy *wiphy = hw->wiphy;
357 struct mt7915_dev *dev = phy->dev;
359 hw->queues = 4;
360 hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE;
361 hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE;
362 hw->netdev_features = NETIF_F_RXCSUM;
364 if (mtk_wed_device_active(&mdev->mmio.wed))
365 hw->netdev_features |= NETIF_F_HW_TC;
367 hw->radiotap_timestamp.units_pos =
370 phy->slottime = 9;
372 hw->sta_data_size = sizeof(struct mt7915_sta);
373 hw->vif_data_size = sizeof(struct mt7915_vif);
375 wiphy->iface_combinations = if_comb;
376 wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
377 wiphy->reg_notifier = mt7915_regd_notifier;
378 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
379 wiphy->mbssid_max_interfaces = 16;
392 if (!is_mt7915(&dev->mt76))
395 if (!mdev->dev->of_node ||
396 !of_property_read_bool(mdev->dev->of_node,
397 "mediatek,disable-radar-background"))
408 hw->max_tx_fragments = 4;
410 if (phy->mt76->cap.has_2ghz) {
411 phy->mt76->sband_2g.sband.ht_cap.cap |=
414 if (is_mt7915(&dev->mt76))
415 phy->mt76->sband_2g.sband.ht_cap.ampdu_density =
418 phy->mt76->sband_2g.sband.ht_cap.ampdu_density =
422 if (phy->mt76->cap.has_5ghz) {
425 vht_cap = &phy->mt76->sband_5g.sband.vht_cap;
426 phy->mt76->sband_5g.sband.ht_cap.cap |=
430 if (is_mt7915(&dev->mt76)) {
431 phy->mt76->sband_5g.sband.ht_cap.ampdu_density =
434 vht_cap->cap |=
438 if (!dev->dbdc_support)
439 vht_cap->cap |=
443 phy->mt76->sband_5g.sband.ht_cap.ampdu_density =
446 vht_cap->cap |=
451 vht_cap->cap |=
456 if (!is_mt7915(&dev->mt76) || !dev->dbdc_support)
460 mt76_set_stream_caps(phy->mt76, true);
465 wiphy->available_antennas_rx = phy->mt76->antenna_mask;
466 wiphy->available_antennas_tx = phy->mt76->antenna_mask;
470 mphy->leds.cdev.brightness_set = mt7915_led_set_brightness;
471 mphy->leds.cdev.blink_set = mt7915_led_set_blink;
523 if (is_mt7915(&dev->mt76))
533 /* filter out non-resp frames and get instanstaeous signal reporting */
542 if (mtk_wed_device_active(&dev->mt76.mmio.wed))
552 if (dev->dbdc_support) {
553 switch (mt76_chip(&dev->mt76)) {
575 } else if (dev->mphy.leds.pin) {
576 switch (mt76_chip(&dev->mt76)) {
593 switch (mt76_chip(&dev->mt76)) {
615 u32 rx_len = is_mt7915(&dev->mt76) ? 0x400 : 0x680;
618 if (!is_mt7915(&dev->mt76) && dev->hif2)
624 if (!is_mt7915(&dev->mt76))
629 /* enable hardware de-agg */
645 if (dev->dbdc_support) {
666 if (!dev->dbdc_support)
669 mphy = mt76_alloc_phy(&dev->mt76, sizeof(*phy), &mt7915_ops, MT_BAND1);
671 return ERR_PTR(-ENOMEM);
673 phy = mphy->priv;
674 phy->dev = dev;
675 phy->mt76 = mphy;
678 phy->mt76->band_idx = 1;
686 struct mt76_phy *mphy = phy->mt76;
689 INIT_DELAYED_WORK(&mphy->mac_work, mt7915_mac_work);
693 memcpy(mphy->macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR2,
698 if (!is_valid_ether_addr(mphy->macaddr)) {
699 memcpy(mphy->macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
701 mphy->macaddr[0] |= 2;
702 mphy->macaddr[0] ^= BIT(7);
742 if (is_mt7915(&dev->mt76)) {
755 /* release wfsys then mcu re-executes romcode */
768 dev_err(dev->mt76.dev, "wifi subsystem reset failure\n");
776 } else if (is_mt798x(&dev->mt76)) {
795 dev->phy.mt76->band_idx = 0;
797 if (is_mt798x(&dev->mt76)) {
801 * for mt7986, dbdc support is determined by the number
806 dev->phy.mt76->band_idx = 1;
810 ret = is_mt7915(&dev->mt76) ?
825 INIT_WORK(&dev->init_work, mt7915_init_work);
831 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
841 if (dev->cal) {
848 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
850 return -ENOSPC;
852 dev->mt76.global_wcid.idx = idx;
853 dev->mt76.global_wcid.hw_key_idx = -1;
854 dev->mt76.global_wcid.tx_info |= MT_WCID_TX_INFO_SET;
855 rcu_assign_pointer(dev->mt76.wcid[idx], &dev->mt76.global_wcid);
865 if (!phy->mt76->cap.has_5ghz)
868 sts = hweight8(phy->mt76->chainmask);
869 cap = &phy->mt76->sband_5g.sband.vht_cap.cap;
874 sts - 1);
886 sts - 1);
893 struct mt7915_dev *dev = phy->dev;
894 struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem;
895 int sts = hweight8(phy->mt76->chainmask);
899 if (is_mt7915(&dev->mt76)) {
900 if (!dev->dbdc_support)
911 elem->phy_cap_info[3] &= ~IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
912 elem->phy_cap_info[4] &= ~IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
917 elem->phy_cap_info[5] &= ~c;
921 elem->phy_cap_info[6] &= ~c;
923 elem->phy_cap_info[7] &= ~IEEE80211_HE_PHY_CAP7_MAX_NC_MASK;
926 if (!is_mt7915(&dev->mt76))
929 elem->phy_cap_info[2] |= c;
935 elem->phy_cap_info[4] |= c;
944 elem->phy_cap_info[6] |= c;
950 elem->phy_cap_info[7] |= min_t(int, sts - 1, 2) << 3;
955 elem->phy_cap_info[3] |= IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
958 sts - 1);
961 sts_160 - 1);
962 elem->phy_cap_info[5] |= c;
967 elem->phy_cap_info[4] |= IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
971 elem->phy_cap_info[6] |= c;
973 if (!is_mt7915(&dev->mt76)) {
976 elem->phy_cap_info[7] |= c;
984 struct mt7915_dev *dev = phy->dev;
985 int i, idx = 0, nss = hweight8(phy->mt76->antenna_mask);
990 if (!is_mt7915(&dev->mt76))
992 else if (!dev->dbdc_support)
1014 &he_cap->he_cap_elem;
1016 &he_cap->he_mcs_nss_supp;
1030 he_cap->has_he = true;
1032 he_cap_elem->mac_cap_info[0] =
1034 he_cap_elem->mac_cap_info[3] =
1037 he_cap_elem->mac_cap_info[4] =
1041 he_cap_elem->phy_cap_info[0] =
1044 he_cap_elem->phy_cap_info[0] =
1048 he_cap_elem->phy_cap_info[0] =
1051 he_cap_elem->phy_cap_info[1] =
1053 he_cap_elem->phy_cap_info[2] =
1059 he_cap_elem->mac_cap_info[0] |=
1061 he_cap_elem->mac_cap_info[2] |=
1063 he_cap_elem->mac_cap_info[4] |=
1065 he_cap_elem->mac_cap_info[5] |=
1067 he_cap_elem->phy_cap_info[3] |=
1070 he_cap_elem->phy_cap_info[6] |=
1073 he_cap_elem->phy_cap_info[9] |=
1078 he_cap_elem->mac_cap_info[1] |=
1082 he_cap_elem->phy_cap_info[0] |=
1085 he_cap_elem->phy_cap_info[0] |=
1088 he_cap_elem->phy_cap_info[1] |=
1091 he_cap_elem->phy_cap_info[3] |=
1094 he_cap_elem->phy_cap_info[6] |=
1098 he_cap_elem->phy_cap_info[7] |=
1101 he_cap_elem->phy_cap_info[8] |=
1105 he_cap_elem->phy_cap_info[8] |=
1108 he_cap_elem->phy_cap_info[9] |=
1119 he_mcs->rx_mcs_80 = cpu_to_le16(mcs_map);
1120 he_mcs->tx_mcs_80 = cpu_to_le16(mcs_map);
1121 he_mcs->rx_mcs_160 = cpu_to_le16(mcs_map_160);
1122 he_mcs->tx_mcs_160 = cpu_to_le16(mcs_map_160);
1126 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
1127 if (he_cap_elem->phy_cap_info[6] &
1129 mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
1131 he_cap_elem->phy_cap_info[9] |=
1162 if (phy->mt76->cap.has_2ghz) {
1163 data = phy->iftype[NL80211_BAND_2GHZ];
1166 band = &phy->mt76->sband_2g.sband;
1170 if (phy->mt76->cap.has_5ghz) {
1171 data = phy->iftype[NL80211_BAND_5GHZ];
1174 band = &phy->mt76->sband_5g.sband;
1178 if (phy->mt76->cap.has_6ghz) {
1179 data = phy->iftype[NL80211_BAND_6GHZ];
1182 band = &phy->mt76->sband_6g.sband;
1190 struct mt76_phy *mphy = dev->mt76.phys[MT_BAND1];
1197 ieee80211_free_hw(mphy->hw);
1203 mt76_connac2_tx_token_put(&dev->mt76);
1205 tasklet_disable(&dev->mt76.irq_tasklet);
1207 if (is_mt798x(&dev->mt76))
1216 dev->phy.dev = dev;
1217 dev->phy.mt76 = &dev->mt76.phy;
1218 dev->mt76.phy.priv = &dev->phy;
1219 INIT_WORK(&dev->rc_work, mt7915_mac_sta_rc_work);
1220 INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7915_mac_work);
1221 INIT_LIST_HEAD(&dev->sta_rc_list);
1222 INIT_LIST_HEAD(&dev->twt_list);
1224 init_waitqueue_head(&dev->reset_wait);
1225 INIT_WORK(&dev->reset_work, mt7915_mac_reset_work);
1226 INIT_WORK(&dev->dump_work, mt7915_mac_dump_work);
1227 mutex_init(&dev->dump_mutex);
1229 dev->dbdc_support = mt7915_band_config(dev);
1239 mt7915_init_wiphy(&dev->phy);
1242 dev->mt76.test_ops = &mt7915_testmode_ops;
1245 ret = mt76_register_device(&dev->mt76, true, mt76_rates,
1250 ret = mt7915_thermal_init(&dev->phy);
1260 ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
1262 dev->recovery.hw_init_done = true;
1264 ret = mt7915_init_debugfs(&dev->phy);
1275 mt7915_unregister_thermal(&dev->phy);
1277 mt76_unregister_device(&dev->mt76);
1282 ieee80211_free_hw(phy2->mt76->hw);
1290 mt7915_unregister_thermal(&dev->phy);
1291 mt76_unregister_device(&dev->mt76);
1294 mt76_free_device(&dev->mt76);