Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp666072pxb; Fri, 16 Apr 2021 15:17:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCSlTX4ygOZgwWGE6rOhrk8eEIac3knQY2k2RQIHK8z4EnKj6k02jC7m1iH/HyT6ETRm6V X-Received: by 2002:a05:6402:1741:: with SMTP id v1mr12439224edx.127.1618611425011; Fri, 16 Apr 2021 15:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618611425; cv=none; d=google.com; s=arc-20160816; b=UmzN2SAi64zV8wICJFUqHMrdlEOyIIsCjTPLqfZ2MO4is3DvqzziPFcLjxNEYv0AaE +dcNQ/iU514nV+B2zXWfWNqIneu6+glztaCvmTv83dA1W2rlC1Pk/DRnhdragyW1qKJ0 M0uV5xV+dRLI3Vodk/unrhRF+XVhn7e0eyA6ACrdW14lpoBNzaD6AcFWMnfmTtdg4giY vpAMEiY3hLqSOODjSu2r0WOYTI7k+8tmZITHgACgF0EjYvgE4m0pJTG7zP4fHAhG/32X Y6LrPr7GLV7dJBeoPZJ/FRE5viLEHS/3ityx1UzM9gj0lQwMiXgRbj0SKmkH6b3QjElc SWqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Obh+BjTOcqhHs5DM3Qb1aPD0UGawMdaGF75ItlYntug=; b=K6GNOppQOhEV5yG73KbwC33EmmgrbBVhvhho7xtMA4ycNv5w0nB7KSJyUsgu7V3y5o w0uJFYw5EQ1tFOqHjTMAr2Pl1kRx7StuyKU8f5r4I6+M4IRWzAGwVdXNW6ap/HJcaqTH CVB9m+KJR+CVs8zR5hjZZYlFHp8exdQgm8sxhMDapGzS+MM8SRwTxGh5oFcqogPgpZ8v wN1O/4FxSqJX/LKGgYgHoU8Yzt4UxtsmvV8pItB53xsETl5+rC+qyAZCp9RruQ31TLvQ 9Ew3LEXHIvq+ZazFv4FTj/4dU+mcUL/aDrab2tLCGoaLX3ycFOyKb6JAXFKfScPAyoxP tioQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si730908edx.505.2021.04.16.15.16.40; Fri, 16 Apr 2021 15:17:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233995AbhDPWQz (ORCPT + 99 others); Fri, 16 Apr 2021 18:16:55 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:54640 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232618AbhDPWQy (ORCPT ); Fri, 16 Apr 2021 18:16:54 -0400 X-UUID: ade985bdd85a4db6b7b8d4138b5efac2-20210417 X-UUID: ade985bdd85a4db6b7b8d4138b5efac2-20210417 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1445916421; Sat, 17 Apr 2021 06:16:22 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 17 Apr 2021 06:16:20 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 17 Apr 2021 06:16:20 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , , , Ryder Lee Subject: [PATCH 1/3] mt76: mt7915: add support for DT rate power limits Date: Sat, 17 Apr 2021 06:16:17 +0800 Message-ID: <6c1be8713dfd1154b5ec61b2b094eb156d9fb659.1618609024.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Shayne Chen Enable to limit per-rate max txpower from DT. Tested-by: Evelyn Tsai Signed-off-by: Shayne Chen Signed-off-by: Ryder Lee --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 44 ++++++++++++++++--- 1 file 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 0b739ed8ce33..3d88a05aad5d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -3375,15 +3375,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, -- 2.18.0