Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1864046pxm; Fri, 4 Mar 2022 05:10:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXQ2nJ1fMXCCJRnu05Ba61mpUA+DFq14Lf+SF6knI8/we0+uY25Pin7+I/AH5BVK4hlRDG X-Received: by 2002:a17:907:9956:b0:6cf:cd25:c5a7 with SMTP id kl22-20020a170907995600b006cfcd25c5a7mr30206544ejc.635.1646399447943; Fri, 04 Mar 2022 05:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646399447; cv=none; d=google.com; s=arc-20160816; b=AxC5i+Dvd0KbEJKphqY9SHh+FzMlmYE0BaHj3mERmPAto1au9y1ZHLUbVQLYwY9qYu WmDcbCFMMr9MuJ0+n0SAgwFsTM0cd+i1x5QcN8aSalYOrhqYMn0VJ+xlGfuS4z3VAW1r XTaL4Uche2z1dtDK2N2whwCBP17e1vFwImIaNQ0bZkSC4cRwc/moWNLjZDEhLeY2A6Tj AT0SmEoMSRb+IWrAbsPq2NNHnugE7iAXhqgJlKKS5lshB97xt1BW8T0d8Z8s0hSjrmf8 8loFtNiDpKwQ0LsG6/reI3FhioHxK1BRq5ciNPyfcU5ogHo6G8SfV8WN8Ms9s+EHDhfV TcBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8YWDAh2/icQqPFEcOG4kkDItFWS23r019Mc1azePFps=; b=PcQt9j0oOJ9JzuT8V4CagqxFqidVAHV7ZFTPXRRB/A2zwIyVFQUnBA9b/oK1MmCWuL 4XoMLP5plI7uJYHa2u04CMss+NcQoXGAFuG59T8qTaccexTQx7qenwGiA4RtMiY/t3Tc sDc8n48N2xuxWOAWAI7OztBf+IpeiY/K77uRDMtGj9gsXBbungIF8D7/CFudOU3VaLTu coFzYsX9eYbwUqy3POrKeUK1AjtMpQLmDM4g71WnR18f51diaIGKcShcEjLNajYF4StF /nL62yJe/rT7ACeu/eZHObsu4Ni8jlCzpDUwI6MI0FS2aCZ6ZBCYUSa5HmkESDazC2w6 SCVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a17090607d500b006d6e97cb3c9si2808153ejc.361.2022.03.04.05.10.01; Fri, 04 Mar 2022 05:10:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbiCDIDB (ORCPT + 72 others); Fri, 4 Mar 2022 03:03:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbiCDICu (ORCPT ); Fri, 4 Mar 2022 03:02:50 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594EC19533D for ; Fri, 4 Mar 2022 00:02:03 -0800 (PST) X-UUID: 42438338abbc4984bac5fe1f56c4ef39-20220304 X-UUID: 42438338abbc4984bac5fe1f56c4ef39-20220304 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1374161258; Fri, 04 Mar 2022 16:02:00 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Fri, 4 Mar 2022 16:01:59 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Mar 2022 16:01:59 +0800 From: MeiChia Chiu To: Felix Fietkau CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , Ryder Lee , , , MeiChia Chiu Subject: [PATCH 4/4] mt76: mt7915: add txpower init for 6GHz Date: Fri, 4 Mar 2022 16:01:20 +0800 Message-ID: <20220304080120.3907-4-MeiChia.Chiu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220304080120.3907-1-MeiChia.Chiu@mediatek.com> References: <20220304080120.3907-1-MeiChia.Chiu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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 3f3ddde0415d..03739f019e76 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); } -- 2.18.0