developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 1 | From 5fe1dd7724e7af4cb508af3147ddc9e1f12d2dc7 Mon Sep 17 00:00:00 2001 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Mon, 31 Jul 2023 11:07:35 +0800 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 4 | Subject: [PATCH 5/7] wifi: mt76: mt7915: rework init txpower |
developer | c879603 | 2023-08-09 10:28:15 +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 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 14 | index d8fd8d6..0d2587c 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 15 | --- a/mt7915/init.c |
| 16 | +++ b/mt7915/init.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 17 | @@ -275,10 +275,11 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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; |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 32 | @@ -296,7 +297,7 @@ void mt7915_init_txpower(struct mt7915_dev *dev, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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; |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 41 | @@ -307,6 +308,19 @@ void mt7915_init_txpower(struct mt7915_dev *dev, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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) |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 61 | @@ -322,9 +336,7 @@ mt7915_regd_notifier(struct wiphy *wiphy, |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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); |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 72 | @@ -445,6 +457,7 @@ mt7915_init_wiphy(struct mt7915_phy *phy) |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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; |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 80 | @@ -708,9 +721,6 @@ static void mt7915_init_work(struct work_struct *work) |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 91 | index d81fae9..a9bdb65 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 106 | index 2c5d929..4293385 100644 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 107 | --- a/mt7915/mt7915.h |
| 108 | +++ b/mt7915/mt7915.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 109 | @@ -430,8 +430,7 @@ void mt7915_dma_cleanup(struct mt7915_dev *dev); |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 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 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 120 | 2.18.0 |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 121 | |