From patchwork Mon Mar 7 07:10:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MeiChia Chiu X-Patchwork-Id: 12771296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F429C433F5 for ; Mon, 7 Mar 2022 07:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RbHpYA/UbMY8LrqMuKAOumoLJQnvbZsPkKgBeiBkkzs=; b=B02gnKoN4KLjSB WUcWSgJ6oSD7oaZ+bIFkgJnof+G77unors1LPs8JaM2NRW78pD1e+5PolAf6+o79K0SYaT9oNmavS 7ztKSEx5ne36Wm+5cN6nFz7AI52FcCXpGGGCBm4cpigX++gkCZWK+hSwgsOTSFgxFZYoEJKGmhl0b HM98jyco5cnw6lORQIuPOHFYwAr5mQKT2JBRm4E0F8fhwBfX9MNtblTCDePfJtzS5k/QKxSsPVWWD hVLzfm67b+EvEeos/YVzWgCe3Rij+3eJgj+1rkY+0z2zgesQ24rIKClgm3RddIubpmhJsMnQk9h+G 3FGrvnHToIQWgkDQTE0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nR7W8-00GFak-Hm; Mon, 07 Mar 2022 07:10:52 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nR7W4-00GFZ1-E5 for linux-mediatek@lists.infradead.org; Mon, 07 Mar 2022 07:10:50 +0000 X-UUID: ebcd90d935854ca6b23d745538c4de17-20220307 X-UUID: ebcd90d935854ca6b23d745538c4de17-20220307 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1818185496; Mon, 07 Mar 2022 00:10:42 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 6 Mar 2022 23:10:40 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Mar 2022 15:10:38 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 7 Mar 2022 15:10:38 +0800 From: MeiChia Chiu To: Felix Fietkau CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , Ryder Lee , , , MeiChia Chiu Subject: [PATCH v3 4/4] mt76: mt7915: add txpower init for 6GHz Date: Mon, 7 Mar 2022 15:10:28 +0800 Message-ID: <20220307071028.5711-4-MeiChia.Chiu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220307071028.5711-1-MeiChia.Chiu@mediatek.com> References: <20220307071028.5711-1-MeiChia.Chiu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220306_231048_486360_0716E388 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Shayne Chen Add support to init txpower values of 6GHz band. Signed-off-by: Shayne Chen Signed-off-by: MeiChia Chiu --- .../net/wireless/mediatek/mt76/mt7915/eeprom.c | 15 +++++++++++---- .../net/wireless/mediatek/mt76/mt7915/eeprom.h | 13 ++++++++++++- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 317c3bc2db44..5b133bcdab17 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -282,8 +282,8 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev, if (!tssi_on) target_power += eeprom[index + 1]; } - } else { - int group = mt7915_get_channel_group(chan->hw_value, is_7976); + } else if (chan->band == NL80211_BAND_5GHZ) { + int group = mt7915_get_channel_group_5g(chan->hw_value, is_7976); if (is_7976) { index = MT_EE_TX0_POWER_5G_V2 + chain_idx * 5; @@ -295,6 +295,11 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev, if (!tssi_on) target_power += eeprom[index + 8]; } + } else { + int group = mt7915_get_channel_group_6g(chan->hw_value); + + index = MT_EE_TX0_POWER_6G_V2 + chain_idx * 8; + target_power = is_7976 ? eeprom[index + group] : 0; } return target_power; @@ -309,12 +314,14 @@ s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band) if (band == NL80211_BAND_2GHZ) offs = is_7976 ? MT_EE_RATE_DELTA_2G_V2 : MT_EE_RATE_DELTA_2G; - else + else if (band == NL80211_BAND_5GHZ) offs = is_7976 ? MT_EE_RATE_DELTA_5G_V2 : MT_EE_RATE_DELTA_5G; + else + offs = is_7976 ? MT_EE_RATE_DELTA_6G_V2 : 0; val = eeprom[offs]; - if (!(val & MT_EE_RATE_DELTA_EN)) + if (!offs || !(val & MT_EE_RATE_DELTA_EN)) return 0; delta = FIELD_GET(MT_EE_RATE_DELTA_MASK, val); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h index 45760917c54d..7578ac6d0be6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h @@ -25,8 +25,10 @@ enum mt7915_eeprom_field { MT_EE_TX0_POWER_5G = 0x34b, MT_EE_RATE_DELTA_2G_V2 = 0x7d3, MT_EE_RATE_DELTA_5G_V2 = 0x81e, + MT_EE_RATE_DELTA_6G_V2 = 0x884, /* 6g fields only appear in eeprom v2 */ MT_EE_TX0_POWER_2G_V2 = 0x441, MT_EE_TX0_POWER_5G_V2 = 0x445, + MT_EE_TX0_POWER_6G_V2 = 0x465, MT_EE_ADIE_FT_VERSION = 0x9a0, __MT_EE_MAX = 0xe00, @@ -103,7 +105,7 @@ enum mt7915_sku_rate_group { }; static inline int -mt7915_get_channel_group(int channel, bool is_7976) +mt7915_get_channel_group_5g(int channel, bool is_7976) { if (is_7976) { if (channel <= 64) @@ -134,6 +136,15 @@ mt7915_get_channel_group(int channel, bool is_7976) return 7; } +static inline int +mt7915_get_channel_group_6g(int channel) +{ + if (channel <= 29) + return 0; + + return DIV_ROUND_UP(channel - 29, 32); +} + static inline bool mt7915_tssi_enabled(struct mt7915_dev *dev, enum nl80211_band band) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 9a696687d61c..668244e0d11e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -312,6 +312,7 @@ mt7915_regd_notifier(struct wiphy *wiphy, mt7915_init_txpower(dev, &mphy->sband_2g.sband); mt7915_init_txpower(dev, &mphy->sband_5g.sband); + mt7915_init_txpower(dev, &mphy->sband_6g.sband); mphy->dfs_state = MT_DFS_STATE_UNKNOWN; mt7915_dfs_init_radar_detector(phy); @@ -558,6 +559,7 @@ static void mt7915_init_work(struct work_struct *work) mt7915_mac_init(dev); mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband); mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband); + mt7915_init_txpower(dev, &dev->mphy.sband_6g.sband); mt7915_txbf_init(dev); }