diff mbox series

[3/3] mt76: mt7921: introduce BIOS SAR config in tx power

Message ID 2e6b69a763d60897639101506e39a2b1a81d8eab.1652941276.git.deren.wu@mediatek.com (mailing list archive)
State Superseded
Delegated to: Felix Fietkau
Headers show
Series introduce BIOS SAR support | expand

Commit Message

Deren Wu May 19, 2022, 6:38 a.m. UTC
From: Deren Wu <deren.wu@mediatek.com>

Add new function mt7921_set_tx_sar_pwr() to update SAR power from
.set_sar_specs and BIOS setting. Both settings would be merged into
mt76_freq_range_power for final tx power value.

Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7921/init.c  |  3 +-
 .../net/wireless/mediatek/mt76/mt7921/main.c  | 32 +++++++++++++------
 .../wireless/mediatek/mt76/mt7921/mt7921.h    |  2 ++
 3 files changed, 26 insertions(+), 11 deletions(-)

Comments

Felix Fietkau May 19, 2022, 3:33 p.m. UTC | #1
On 19.05.22 08:38, Deren Wu wrote:
> From: Deren Wu <deren.wu@mediatek.com>
> 
> Add new function mt7921_set_tx_sar_pwr() to update SAR power from
> .set_sar_specs and BIOS setting. Both settings would be merged into
> mt76_freq_range_power for final tx power value.
> 
> Reviewed-by: Sean Wang <sean.wang@mediatek.com>
> Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
> Signed-off-by: Deren Wu <deren.wu@mediatek.com>
> ---
>   .../net/wireless/mediatek/mt76/mt7921/init.c  |  3 +-
>   .../net/wireless/mediatek/mt76/mt7921/main.c  | 32 +++++++++++++------
>   .../wireless/mediatek/mt76/mt7921/mt7921.h    |  2 ++
>   3 files changed, 26 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 80279f342109..c86d8805f291 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -1469,20 +1469,34 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,
>   }
>   #endif
>   
> +int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
> +			  const struct cfg80211_sar_specs *sar)
> +{
> +	struct mt76_phy *mphy = hw->priv;
> +	int err;
> +
> +	if (sar) {
> +		err = mt76_init_sar_power(hw, sar);
> +		if (err)
> +			return err;
> +	}
> +
> +	mt7921_init_bios_sar_power(mt7921_hw_phy(hw), !sar);
> +
> +	err = mt76_connac_mcu_set_rate_txpower(mphy);
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(mt7921_set_tx_sar_pwr);
Why is this exported?

- Felix
Deren Wu May 19, 2022, 4:22 p.m. UTC | #2
Hi Felix,

On Thu, 2022-05-19 at 17:33 +0200, Felix Fietkau wrote:
> On 19.05.22 08:38, Deren Wu wrote:
> > From: Deren Wu <deren.wu@mediatek.com>
> > 
> > Add new function mt7921_set_tx_sar_pwr() to update SAR power from
> > .set_sar_specs and BIOS setting. Both settings would be merged into
> > mt76_freq_range_power for final tx power value.
> > 
> > Reviewed-by: Sean Wang <sean.wang@mediatek.com>
> > Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
> > Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
> > Signed-off-by: Deren Wu <deren.wu@mediatek.com>
> > ---
> >   .../net/wireless/mediatek/mt76/mt7921/init.c  |  3 +-
> >   .../net/wireless/mediatek/mt76/mt7921/main.c  | 32 +++++++++++++-
> > -----
> >   .../wireless/mediatek/mt76/mt7921/mt7921.h    |  2 ++
> >   3 files changed, 26 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> > b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> > index 80279f342109..c86d8805f291 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> > @@ -1469,20 +1469,34 @@ static void mt7921_ipv6_addr_change(struct
> > ieee80211_hw *hw,
> >   }
> >   #endif
> >   
> > +int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
> > +			  const struct cfg80211_sar_specs *sar)
> > +{
> > +	struct mt76_phy *mphy = hw->priv;
> > +	int err;
> > +
> > +	if (sar) {
> > +		err = mt76_init_sar_power(hw, sar);
> > +		if (err)
> > +			return err;
> > +	}
> > +
> > +	mt7921_init_bios_sar_power(mt7921_hw_phy(hw), !sar);
> > +
> > +	err = mt76_connac_mcu_set_rate_txpower(mphy);
> > +
> > +	return err;
> > +}
> > +EXPORT_SYMBOL_GPL(mt7921_set_tx_sar_pwr);
> 
> Why is this exported?

Thanks for pointing out. I will remove unnecessary export in next
version.


Regards,
Deren

> 
> - Felix
> 
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
index ae406f1b31a0..4043c81bfbca 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
@@ -34,14 +34,13 @@  mt7921_regd_notifier(struct wiphy *wiphy,
 {
 	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
 	struct mt7921_dev *dev = mt7921_hw_dev(hw);
-	struct mt7921_phy *phy = mt7921_hw_phy(hw);
 
 	memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2));
 	dev->mt76.region = request->dfs_region;
 
 	mt7921_mutex_acquire(dev);
 	mt76_connac_mcu_set_channel_domain(hw->priv);
-	mt76_connac_mcu_set_rate_txpower(phy->mt76);
+	mt7921_set_tx_sar_pwr(hw, NULL);
 	mt7921_mutex_release(dev);
 }
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 80279f342109..c86d8805f291 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -257,7 +257,7 @@  int __mt7921_start(struct mt7921_phy *phy)
 	if (err)
 		return err;
 
-	err = mt76_connac_mcu_set_rate_txpower(phy->mt76);
+	err = mt7921_set_tx_sar_pwr(mphy->hw, NULL);
 	if (err)
 		return err;
 
@@ -548,7 +548,7 @@  static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
 	mt7921_mutex_acquire(dev);
 
 	if (changed & IEEE80211_CONF_CHANGE_POWER) {
-		ret = mt76_connac_mcu_set_rate_txpower(phy->mt76);
+		ret = mt7921_set_tx_sar_pwr(hw, NULL);
 		if (ret)
 			goto out;
 	}
@@ -1469,20 +1469,34 @@  static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,
 }
 #endif
 
+int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
+			  const struct cfg80211_sar_specs *sar)
+{
+	struct mt76_phy *mphy = hw->priv;
+	int err;
+
+	if (sar) {
+		err = mt76_init_sar_power(hw, sar);
+		if (err)
+			return err;
+	}
+
+	mt7921_init_bios_sar_power(mt7921_hw_phy(hw), !sar);
+
+	err = mt76_connac_mcu_set_rate_txpower(mphy);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(mt7921_set_tx_sar_pwr);
+
 static int mt7921_set_sar_specs(struct ieee80211_hw *hw,
 				const struct cfg80211_sar_specs *sar)
 {
 	struct mt7921_dev *dev = mt7921_hw_dev(hw);
-	struct mt76_phy *mphy = hw->priv;
 	int err;
 
 	mt7921_mutex_acquire(dev);
-	err = mt76_init_sar_power(hw, sar);
-	if (err)
-		goto out;
-
-	err = mt76_connac_mcu_set_rate_txpower(mphy);
-out:
+	err = mt7921_set_tx_sar_pwr(hw, sar);
 	mt7921_mutex_release(dev);
 
 	return err;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index e5d541291919..a63c4848ced4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -501,4 +501,6 @@  mt7921_init_bios_sar_power(struct mt7921_phy *phy, bool set_default)
 	return 0;
 }
 #endif
+int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
+			  const struct cfg80211_sar_specs *sar);
 #endif