blob: e6ddc58d0da2aa77d8c9a815d7f61931797f5071 [file] [log] [blame]
developerb85e8752023-09-25 14:16:05 +08001From 5fe1dd7724e7af4cb508af3147ddc9e1f12d2dc7 Mon Sep 17 00:00:00 2001
developerc8796032023-08-09 10:28:15 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Mon, 31 Jul 2023 11:07:35 +0800
developerb85e8752023-09-25 14:16:05 +08004Subject: [PATCH 5/7] wifi: mt76: mt7915: rework init txpower
developerc8796032023-08-09 10:28:15 +08005
6Signed-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
13diff --git a/mt7915/init.c b/mt7915/init.c
developerb85e8752023-09-25 14:16:05 +080014index d8fd8d6..0d2587c 100644
developerc8796032023-08-09 10:28:15 +080015--- a/mt7915/init.c
16+++ b/mt7915/init.c
developerb85e8752023-09-25 14:16:05 +080017@@ -275,10 +275,11 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev,
developerc8796032023-08-09 10:28:15 +080018 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;
developerb85e8752023-09-25 14:16:05 +080032@@ -296,7 +297,7 @@ void mt7915_init_txpower(struct mt7915_dev *dev,
developerc8796032023-08-09 10:28:15 +080033 }
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;
developerb85e8752023-09-25 14:16:05 +080041@@ -307,6 +308,19 @@ void mt7915_init_txpower(struct mt7915_dev *dev,
developerc8796032023-08-09 10:28:15 +080042 }
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)
developerb85e8752023-09-25 14:16:05 +080061@@ -322,9 +336,7 @@ mt7915_regd_notifier(struct wiphy *wiphy,
developerc8796032023-08-09 10:28:15 +080062 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);
developerb85e8752023-09-25 14:16:05 +080072@@ -445,6 +457,7 @@ mt7915_init_wiphy(struct mt7915_phy *phy)
developerc8796032023-08-09 10:28:15 +080073 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;
developerb85e8752023-09-25 14:16:05 +080080@@ -708,9 +721,6 @@ static void mt7915_init_work(struct work_struct *work)
developerc8796032023-08-09 10:28:15 +080081
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
90diff --git a/mt7915/mac.c b/mt7915/mac.c
developerb85e8752023-09-25 14:16:05 +080091index d81fae9..a9bdb65 100644
developerc8796032023-08-09 10:28:15 +080092--- 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)) {
105diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerb85e8752023-09-25 14:16:05 +0800106index 2c5d929..4293385 100644
developerc8796032023-08-09 10:28:15 +0800107--- a/mt7915/mt7915.h
108+++ b/mt7915/mt7915.h
developerb85e8752023-09-25 14:16:05 +0800109@@ -430,8 +430,7 @@ void mt7915_dma_cleanup(struct mt7915_dev *dev);
developerc8796032023-08-09 10:28:15 +0800110 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--
developerb85e8752023-09-25 14:16:05 +08001202.18.0
developerc8796032023-08-09 10:28:15 +0800121