Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2253282pxm; Fri, 4 Mar 2022 12:23:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRkT/Gj+Ejdy6hcX90LVhVX5Uz5OWJOFDI2ZSAHloSGQtHTgkitp1r3UcR6GlJQ6bVblVB X-Received: by 2002:a17:902:f548:b0:151:b6bf:17f7 with SMTP id h8-20020a170902f54800b00151b6bf17f7mr186385plf.56.1646425424555; Fri, 04 Mar 2022 12:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646425424; cv=none; d=google.com; s=arc-20160816; b=NpwOHr8CoRHcUXTUUosmwWjavxCN6Pjw88K2VvO0L5+ivGLc2x4aMcYlm6jQSDmAjm cCU8ZHk1X0wLEo/JwM3m4EgWgDy2uwGgHY2dzZu4yhTT5lSlkXHzJaZAalBK5d4emVIf PjouT0AzaSGI/UA2eEtGmHlW0oaL0VFVk+VtJdz1gRngvHMMqJD6uIRlWwkYFITv2z3v gDOsVoiUmJdObFnHZ+wsIknjqLifh5Wl00+GFkYo6HDsHCgjnvrIQ+fCq7AVuTuH1rJ1 X4MEybZxoXj1Qs7Rmo4yuNXx8KVE9B7zVkTgE/yJlBupj88cAy7ELMy8+1eowYEOe4wI yuwQ== 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=8ZFehey7i6N0Wx/uWKe/HWyQmQ84wOL1MLYu1rucprI=; b=bl3Nxe6FKUgFAnNR8QTQH8z3+H6Sa66jpogO7K+drJQ/RiuQ07UonRb661MbNYYu1f weE52iobvubQpDNbuKIIj6PTA56n6oR6gQ8MUa0Dy7lF1smNxGNKmGi9YsVoyxxLK2Jl QC+1T2zRbI90tv74kwo3rfjPLJV74LS/U30LQv2tlNZMelH/Vw76Zloi1vspiEHJM7jx VRLWYeYQqGjghvP2ftRkkvML3BF9jlsR8EFA/BUQvH+pF0aaCILtoi3xQ2PhnhxZ5I6J 3SlU3xwppCI9eGoVaaNdk0gqMIJp6DytJ049RUfmy1e1yq/1UCpRnUrBT2ifpde+4I/7 X3Qw== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z69-20020a633348000000b0036fe3b212cfsi5694938pgz.602.2022.03.04.12.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:23:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7CC7B286883; Fri, 4 Mar 2022 11:32:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbiCDIDC (ORCPT + 72 others); Fri, 4 Mar 2022 03:03:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbiCDICt (ORCPT ); Fri, 4 Mar 2022 03:02:49 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E50C19533A for ; Fri, 4 Mar 2022 00:02:01 -0800 (PST) X-UUID: 361d5ffa6d154d77bfcbf9b5c6003db3-20220304 X-UUID: 361d5ffa6d154d77bfcbf9b5c6003db3-20220304 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 519321481; Fri, 04 Mar 2022 16:01:57 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Mar 2022 16:01:56 +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:56 +0800 From: MeiChia Chiu To: Felix Fietkau CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , Ryder Lee , , , MeiChia Chiu Subject: [PATCH 3/4] mt76: mt7915: fix eeprom fields of txpower init values Date: Fri, 4 Mar 2022 16:01:19 +0800 Message-ID: <20220304080120.3907-3-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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 A-die 7976 has different offset and uses different channel group definition on txpower init values. Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986") Signed-off-by: Shayne Chen Signed-off-by: MeiChia Chiu --- .../wireless/mediatek/mt76/mt7915/eeprom.c | 52 ++++++++++--------- .../wireless/mediatek/mt76/mt7915/eeprom.h | 14 ++++- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 136a6adab3df..317c3bc2db44 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -263,32 +263,38 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev, { u8 *eeprom = dev->mt76.eeprom.data; int index, target_power; - bool tssi_on; + bool tssi_on, is_7976; if (chain_idx > 3) return -EINVAL; tssi_on = mt7915_tssi_enabled(dev, chan->band); + is_7976 = mt7915_check_adie(dev, false) || is_mt7916(&dev->mt76); if (chan->band == NL80211_BAND_2GHZ) { - u32 power = is_mt7915(&dev->mt76) ? - MT_EE_TX0_POWER_2G : MT_EE_TX0_POWER_2G_V2; - - index = power + chain_idx * 3; - target_power = eeprom[index]; + if (is_7976) { + index = MT_EE_TX0_POWER_2G_V2 + chain_idx; + target_power = eeprom[index]; + } else { + index = MT_EE_TX0_POWER_2G + chain_idx * 3; + target_power = eeprom[index]; - if (!tssi_on) - target_power += eeprom[index + 1]; + if (!tssi_on) + target_power += eeprom[index + 1]; + } } else { - int group = mt7915_get_channel_group(chan->hw_value); - u32 power = is_mt7915(&dev->mt76) ? - MT_EE_TX0_POWER_5G : MT_EE_TX0_POWER_5G_V2; + int group = mt7915_get_channel_group(chan->hw_value, is_7976); - index = power + chain_idx * 12; - target_power = eeprom[index + group]; + if (is_7976) { + index = MT_EE_TX0_POWER_5G_V2 + chain_idx * 5; + target_power = eeprom[index + group]; + } else { + index = MT_EE_TX0_POWER_5G + chain_idx * 12; + target_power = eeprom[index + group]; - if (!tssi_on) - target_power += eeprom[index + 8]; + if (!tssi_on) + target_power += eeprom[index + 8]; + } } return target_power; @@ -297,20 +303,16 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev, s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band) { u8 *eeprom = dev->mt76.eeprom.data; - u32 val; + u32 val, offs; s8 delta; - u32 rate_2g, rate_5g; - - rate_2g = is_mt7915(&dev->mt76) ? - MT_EE_RATE_DELTA_2G : MT_EE_RATE_DELTA_2G_V2; - - rate_5g = is_mt7915(&dev->mt76) ? - MT_EE_RATE_DELTA_5G : MT_EE_RATE_DELTA_5G_V2; + bool is_7976 = mt7915_check_adie(dev, false) || is_mt7916(&dev->mt76); if (band == NL80211_BAND_2GHZ) - val = eeprom[rate_2g]; + offs = is_7976 ? MT_EE_RATE_DELTA_2G_V2 : MT_EE_RATE_DELTA_2G; else - val = eeprom[rate_5g]; + offs = is_7976 ? MT_EE_RATE_DELTA_5G_V2 : MT_EE_RATE_DELTA_5G; + + val = eeprom[offs]; if (!(val & MT_EE_RATE_DELTA_EN)) return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h index 5dad5b0b5ac6..45760917c54d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h @@ -103,8 +103,20 @@ enum mt7915_sku_rate_group { }; static inline int -mt7915_get_channel_group(int channel) +mt7915_get_channel_group(int channel, bool is_7976) { + if (is_7976) { + if (channel <= 64) + return 0; + if (channel <= 96) + return 1; + if (channel <= 128) + return 2; + if (channel <= 144) + return 3; + return 4; + } + if (channel >= 184 && channel <= 196) return 0; if (channel <= 48) -- 2.18.0