developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 1 | From 738d720905afdf9abcb85cb6d6e8cd48a69cb82f Mon Sep 17 00:00:00 2001 |
developer | 36b5cff | 2023-08-02 17:18:21 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Mon, 31 Jul 2023 11:07:35 +0800 |
developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 4 | Subject: [PATCH 13/15] wifi: mt76: mt7915: rework init txpower |
developer | 36b5cff | 2023-08-02 17:18:21 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 7 | --- |
| 8 | mt7915/init.c | 30 ++++++++++++++++++++---------- |
| 9 | mt7915/mac.c | 4 ++-- |
| 10 | mt7915/mt7915.h | 3 +-- |
| 11 | 3 files changed, 23 insertions(+), 14 deletions(-) |
| 12 | |
| 13 | diff --git a/mt7915/init.c b/mt7915/init.c |
| 14 | index 15b719fa..5ac1f995 100644 |
| 15 | --- a/mt7915/init.c |
| 16 | +++ b/mt7915/init.c |
| 17 | @@ -278,10 +278,11 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev, |
| 18 | mt7915_led_set_config(led_cdev, 0xff, 0); |
| 19 | } |
| 20 | |
| 21 | -void mt7915_init_txpower(struct mt7915_dev *dev, |
| 22 | - struct ieee80211_supported_band *sband) |
| 23 | +void __mt7915_init_txpower(struct mt7915_phy *phy, |
| 24 | + struct ieee80211_supported_band *sband) |
| 25 | { |
| 26 | - int i, n_chains = hweight16(dev->mphy.chainmask); |
| 27 | + struct mt7915_dev *dev = phy->dev; |
| 28 | + int i, n_chains = hweight16(phy->mt76->chainmask); |
| 29 | int nss_delta = mt76_tx_power_nss_delta(n_chains); |
| 30 | int pwr_delta = mt7915_eeprom_get_power_delta(dev, sband->band); |
| 31 | struct mt76_power_limits limits; |
| 32 | @@ -299,7 +300,7 @@ void mt7915_init_txpower(struct mt7915_dev *dev, |
| 33 | } |
| 34 | |
| 35 | target_power += pwr_delta; |
| 36 | - target_power = mt76_get_rate_power_limits(&dev->mphy, chan, |
| 37 | + target_power = mt76_get_rate_power_limits(phy->mt76, chan, |
| 38 | &limits, |
| 39 | target_power); |
| 40 | target_power += nss_delta; |
| 41 | @@ -310,6 +311,19 @@ void mt7915_init_txpower(struct mt7915_dev *dev, |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | +void mt7915_init_txpower(struct mt7915_phy *phy) |
| 46 | +{ |
| 47 | + if (!phy) |
| 48 | + return; |
| 49 | + |
| 50 | + if (phy->mt76->cap.has_2ghz) |
| 51 | + __mt7915_init_txpower(phy, &phy->mt76->sband_2g.sband); |
| 52 | + if (phy->mt76->cap.has_5ghz) |
| 53 | + __mt7915_init_txpower(phy, &phy->mt76->sband_5g.sband); |
| 54 | + if (phy->mt76->cap.has_6ghz) |
| 55 | + __mt7915_init_txpower(phy, &phy->mt76->sband_6g.sband); |
| 56 | +} |
| 57 | + |
| 58 | static void |
| 59 | mt7915_regd_notifier(struct wiphy *wiphy, |
| 60 | struct regulatory_request *request) |
| 61 | @@ -325,9 +339,7 @@ mt7915_regd_notifier(struct wiphy *wiphy, |
| 62 | if (dev->mt76.region == NL80211_DFS_UNSET) |
| 63 | mt7915_mcu_rdd_background_enable(phy, NULL); |
| 64 | |
| 65 | - mt7915_init_txpower(dev, &mphy->sband_2g.sband); |
| 66 | - mt7915_init_txpower(dev, &mphy->sband_5g.sband); |
| 67 | - mt7915_init_txpower(dev, &mphy->sband_6g.sband); |
| 68 | + mt7915_init_txpower(phy); |
| 69 | |
| 70 | mphy->dfs_state = MT_DFS_STATE_UNKNOWN; |
| 71 | mt7915_dfs_init_radar_detector(phy); |
| 72 | @@ -448,6 +460,7 @@ mt7915_init_wiphy(struct mt7915_phy *phy) |
| 73 | mt76_set_stream_caps(phy->mt76, true); |
| 74 | mt7915_set_stream_vht_txbf_caps(phy); |
| 75 | mt7915_set_stream_he_caps(phy); |
| 76 | + mt7915_init_txpower(phy); |
| 77 | |
| 78 | wiphy->available_antennas_rx = phy->mt76->antenna_mask; |
| 79 | wiphy->available_antennas_tx = phy->mt76->antenna_mask; |
| 80 | @@ -711,9 +724,6 @@ static void mt7915_init_work(struct work_struct *work) |
| 81 | |
| 82 | mt7915_mcu_set_eeprom(dev); |
| 83 | mt7915_mac_init(dev); |
| 84 | - mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband); |
| 85 | - mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband); |
| 86 | - mt7915_init_txpower(dev, &dev->mphy.sband_6g.sband); |
| 87 | mt7915_txbf_init(dev); |
| 88 | } |
| 89 | |
| 90 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
| 91 | index 67e7b264..d9d5aad4 100644 |
| 92 | --- a/mt7915/mac.c |
| 93 | +++ b/mt7915/mac.c |
| 94 | @@ -1395,8 +1395,8 @@ mt7915_mac_restart(struct mt7915_dev *dev) |
| 95 | goto out; |
| 96 | |
| 97 | mt7915_mac_init(dev); |
| 98 | - mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband); |
| 99 | - mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband); |
| 100 | + mt7915_init_txpower(&dev->phy); |
| 101 | + mt7915_init_txpower(phy2); |
| 102 | ret = mt7915_txbf_init(dev); |
| 103 | |
| 104 | if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) { |
| 105 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
| 106 | index eb66fcda..f0809291 100644 |
| 107 | --- a/mt7915/mt7915.h |
| 108 | +++ b/mt7915/mt7915.h |
| 109 | @@ -428,8 +428,7 @@ void mt7915_dma_cleanup(struct mt7915_dev *dev); |
| 110 | int mt7915_dma_reset(struct mt7915_dev *dev, bool force); |
| 111 | int mt7915_dma_start(struct mt7915_dev *dev, bool reset, bool wed_reset); |
| 112 | int mt7915_txbf_init(struct mt7915_dev *dev); |
| 113 | -void mt7915_init_txpower(struct mt7915_dev *dev, |
| 114 | - struct ieee80211_supported_band *sband); |
| 115 | +void mt7915_init_txpower(struct mt7915_phy *phy); |
| 116 | void mt7915_reset(struct mt7915_dev *dev); |
| 117 | int mt7915_run(struct ieee80211_hw *hw); |
| 118 | int mt7915_mcu_init(struct mt7915_dev *dev); |
| 119 | -- |
| 120 | 2.39.2 |
| 121 | |