Commit 148950e5 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: mt7615: introduce SAR support



Add SAR spec support to mt7615 driver to allow configuring SAR power
limitations on the frequency ranges from the userland.

Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 28225a6e
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -431,6 +431,29 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
	return err;
}

static int mt7615_set_sar_specs(struct ieee80211_hw *hw,
				const struct cfg80211_sar_specs *sar)
{
	struct mt7615_phy *phy = mt7615_hw_phy(hw);
	int err;

	if (!cfg80211_chandef_valid(&phy->mt76->chandef))
		return -EINVAL;

	err = mt76_init_sar_power(hw, sar);
	if (err)
		return err;

	if (mt7615_firmware_offload(phy->dev))
		return mt76_connac_mcu_set_rate_txpower(phy->mt76);

	ieee80211_stop_queues(hw);
	err = mt7615_set_channel(phy);
	ieee80211_wake_queues(hw);

	return err;
}

static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
{
	struct mt7615_dev *dev = mt7615_hw_dev(hw);
@@ -1333,6 +1356,7 @@ const struct ieee80211_ops mt7615_ops = {
	.set_wakeup = mt7615_set_wakeup,
	.set_rekey_data = mt7615_set_rekey_data,
#endif /* CONFIG_PM */
	.set_sar_specs = mt7615_set_sar_specs,
};
EXPORT_SYMBOL_GPL(mt7615_ops);

+3 −4
Original line number Diff line number Diff line
@@ -2020,7 +2020,7 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku)
	struct mt76_power_limits limits;
	s8 *limits_array = (s8 *)&limits;
	int n_chains = hweight8(mphy->antenna_mask);
	int tx_power;
	int tx_power = hw->conf.power_level * 2;
	int i;
	static const u8 sku_mapping[] = {
#define SKU_FIELD(_type, _field) \
@@ -2077,9 +2077,8 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku)
#undef SKU_FIELD
	};

	tx_power = hw->conf.power_level * 2 -
		   mt76_tx_power_nss_delta(n_chains);

	tx_power = mt76_get_sar_power(mphy, mphy->chandef.chan, tx_power);
	tx_power -= mt76_tx_power_nss_delta(n_chains);
	tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
					      &limits, tx_power);
	mphy->txpower_cur = tx_power;