summaryrefslogtreecommitdiff
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorShayne Chen <shayne.chen@mediatek.com>2021-04-17 06:16:17 +0800
committerFelix Fietkau <nbd@nbd.name>2021-04-21 12:20:54 +0200
commit790d228a68745624c266c27aded0d7f46a0d5af4 (patch)
treecca92216d2d9b59ac7fcd0a1d4791a05746d8cdc /drivers/net/wireless
parente513ae49088bbb0d00299a9f996f88f08cca7dc6 (diff)
mt76: mt7915: add support for DT rate power limits
Enable to limit per-rate max txpower from DT. Tested-by: Evelyn Tsai <evelyn.tsai@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7915/mcu.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 1a7c36cb435b..74c375910eb7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3517,15 +3517,47 @@ int mt7915_mcu_set_sku(struct mt7915_phy *phy)
.format_id = 4,
.dbdc_idx = phy != &dev->phy,
};
- int i;
- s8 *delta;
+ struct mt76_power_limits limits_array;
+ s8 *delta, *la = (s8 *)&limits_array;
+ int i, idx, n_chains = hweight8(mphy->antenna_mask);
+ int tx_power;
delta = dev->rate_power[mphy->chandef.chan->band];
- mphy->txpower_cur = hw->conf.power_level * 2 +
- delta[MT7915_SKU_MAX_DELTA_IDX];
+ tx_power = hw->conf.power_level * 2 -
+ mt76_tx_power_nss_delta(n_chains);
+
+ tx_power = mt76_get_rate_power_limits(mphy, mphy->chandef.chan,
+ &limits_array, tx_power);
+ mphy->txpower_cur = tx_power;
+
+ for (i = 0, idx = 0; i < MAX_SKU_RATE_GROUP_NUM; i++) {
+ const struct sku_group *sku = &mt7915_sku_groups[i];
+ u32 offset = sku->offset[mphy->chandef.chan->band];
+ u8 mcs_num = sku->len;
+ int j;
+
+ if (i >= SKU_HT_BW20 && i <= SKU_VHT_BW160) {
+ mcs_num = 10;
+
+ if (i == SKU_HT_BW20 || i == SKU_VHT_BW20)
+ la = (s8 *)&limits_array + 12;
+ }
- for (i = 0; i < MT7915_SKU_RATE_NUM; i++)
- req.val[i] = hw->conf.power_level * 2 + delta[i];
+ if (!offset) {
+ idx += sku->len;
+ la += mcs_num;
+ continue;
+ }
+
+ for (j = 0; j < min_t(u8, mcs_num, sku->len); j++) {
+ s8 rate_power;
+
+ rate_power = hw->conf.power_level * 2 + delta[idx + j];
+ req.val[idx + j] = min_t(s8, la[j], rate_power);
+ }
+ la += mcs_num;
+ idx += sku->len;
+ }
return mt76_mcu_send_msg(&dev->mt76,
MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,