Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2333710iob; Fri, 20 May 2022 07:11:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypmxwj6eSFwp1LaHg2qp5hOJiyOCLbrXB/e7nIVR7rN6TWHEp418F0ZRvmWj/2/Vz1wlN/ X-Received: by 2002:a17:902:e0d4:b0:161:74ba:9def with SMTP id e20-20020a170902e0d400b0016174ba9defmr10081806pla.28.1653055861455; Fri, 20 May 2022 07:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653055861; cv=none; d=google.com; s=arc-20160816; b=J1WN6aym6J8ubelATzFZW/uI7NOyXBMSsR7AVjA7ayDjaeBsl9LWQECWpnSVbLyLaW bjTymwWyJk8+pGrBRAYNpE+uO/s4ZxN3KD2gRFbCditZgejy1O4i6qVe0ODKJLS3xU5E 0qJoQRX8iuaEjv6fNe/c8U1oa8kxqBV0ZC2wjYkA+70HdRzgd/tdE9uu42gYDu4RHAZl IMoT8MZHGMIzoDtv3fc9ZdEi16aIF4R+YYW2maEiPvKzLD5yV1V9K8HBMdXWcHMmwtfa tu6BVb6+6RaCldjSYzJb6hFWwpqw7Tt2FUhs8SBr9o2j0DPFmdv+qfP8DVRMW7Amqjue G/Tw== 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=C/nvV2Mmp7vcolXf+D927BoimMhgvq/soZbl+eckX2s=; b=HVUOZRylpqOiAdcuWdXBWWMWwXsUUcMsoip9UrmmW96dKkqJkdaq8/6nGxnfdgfCKN eoTC4vN3nYW7E/Jk5GOo1HvnbSPniysBAdcS1zX6UDosasyobScPge9J5ZNdeK6asEhp 4o4KWSPe0Zg5cttrxZqyjgiZOcvhc2EK9dygnDCUqA6PiwMTmVri8A39UDaMy6uaBMvi jb5EWOcX8nM7eLw5nzNjHkZw78uYT6qdzePFXVLpdQdYJ43/xQv0dIKwf2ZAqAYcOiVk 2KJlsg2aEp2OOumcneoUcsoT3OTVFiVTasrtRWKpI4NusMS8s5m8Zp7yvW2YaYsHcBk/ qhyg== 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 c9-20020a170902724900b0015872db9713si9772090pll.131.2022.05.20.07.10.23; Fri, 20 May 2022 07:11:01 -0700 (PDT) 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 S1347324AbiETJEN (ORCPT + 69 others); Fri, 20 May 2022 05:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345270AbiETJEL (ORCPT ); Fri, 20 May 2022 05:04:11 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281C8EBA93 for ; Fri, 20 May 2022 02:04:10 -0700 (PDT) X-UUID: ca723ae28a8e4baa8e5479c87d53e56a-20220520 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:036f244f-e6cd-4412-a6a9-dbeec8727a28,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,RULE:Release_Ham,A CTION:release,TS:100 X-CID-INFO: VERSION:1.1.5,REQID:036f244f-e6cd-4412-a6a9-dbeec8727a28,OB:0,LOB: 0,IP:0,URL:5,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,RULE:Spam_GS981B3D,A CTION:quarantine,TS:100 X-CID-META: VersionHash:2a19b09,CLOUDID:a814efe2-edbf-4bd4-8a34-dfc5f7bb086d,C OID:c8c7156697e9,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,QS:0,BEC:nil X-UUID: ca723ae28a8e4baa8e5479c87d53e56a-20220520 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1112631103; Fri, 20 May 2022 17:04:04 +0800 Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 20 May 2022 17:04:03 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 20 May 2022 17:04:03 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Fri, 20 May 2022 17:04:03 +0800 From: Deren Wu To: Felix Fietkau , Lorenzo Bianconi CC: Sean Wang , Soul Huang , YN Chen , Leon Yen , "Eric-SY Chang" , Deren Wu , KM Lin , Robin Chiu , CH Yeh , Posh Sun , Eric Liang , Stella Chang , "Evelyn Tsai" , Ryder Lee , "Shayne Chen" , linux-wireless , linux-mediatek , Deren Wu , "Ming Yen Hsieh" Subject: [PATCH v2 3/3] mt76: mt7921: introduce ACPI SAR config in tx power Date: Fri, 20 May 2022 17:03:39 +0800 Message-ID: <777ef51ddf8d871b16a634c8e220787b2e8a7e01.1653032296.git.deren.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: 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_PASS, 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: Deren Wu Add new function mt7921_set_tx_sar_pwr() to update SAR power from .set_sar_specs and ACPI setting. Both settings would be merged into mt76_freq_range_power for final tx power value. Reviewed-by: Sean Wang Co-developed-by: Ming Yen Hsieh Signed-off-by: Ming Yen Hsieh Signed-off-by: Deren Wu --- .../net/wireless/mediatek/mt76/mt7921/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7921/main.c | 31 +++++++++++++------ .../wireless/mediatek/mt76/mt7921/mt7921.h | 2 ++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index 0c4e973d002e..48a10aaecc62 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -34,14 +34,13 @@ mt7921_regd_notifier(struct wiphy *wiphy, { struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); struct mt7921_dev *dev = mt7921_hw_dev(hw); - struct mt7921_phy *phy = mt7921_hw_phy(hw); memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2)); dev->mt76.region = request->dfs_region; mt7921_mutex_acquire(dev); mt76_connac_mcu_set_channel_domain(hw->priv); - mt76_connac_mcu_set_rate_txpower(phy->mt76); + mt7921_set_tx_sar_pwr(hw, NULL); mt7921_mutex_release(dev); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 80279f342109..acf6567368b7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -257,7 +257,7 @@ int __mt7921_start(struct mt7921_phy *phy) if (err) return err; - err = mt76_connac_mcu_set_rate_txpower(phy->mt76); + err = mt7921_set_tx_sar_pwr(mphy->hw, NULL); if (err) return err; @@ -548,7 +548,7 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed) mt7921_mutex_acquire(dev); if (changed & IEEE80211_CONF_CHANGE_POWER) { - ret = mt76_connac_mcu_set_rate_txpower(phy->mt76); + ret = mt7921_set_tx_sar_pwr(hw, NULL); if (ret) goto out; } @@ -1469,20 +1469,33 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, } #endif +int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw, + const struct cfg80211_sar_specs *sar) +{ + struct mt76_phy *mphy = hw->priv; + int err; + + if (sar) { + err = mt76_init_sar_power(hw, sar); + if (err) + return err; + } + + mt7921_init_acpi_sar_power(mt7921_hw_phy(hw), !sar); + + err = mt76_connac_mcu_set_rate_txpower(mphy); + + return err; +} + static int mt7921_set_sar_specs(struct ieee80211_hw *hw, const struct cfg80211_sar_specs *sar) { struct mt7921_dev *dev = mt7921_hw_dev(hw); - struct mt76_phy *mphy = hw->priv; int err; mt7921_mutex_acquire(dev); - err = mt76_init_sar_power(hw, sar); - if (err) - goto out; - - err = mt76_connac_mcu_set_rate_txpower(mphy); -out: + err = mt7921_set_tx_sar_pwr(hw, sar); mt7921_mutex_release(dev); return err; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 8b26bece28ae..d9fc457e420d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -501,4 +501,6 @@ mt7921_init_acpi_sar_power(struct mt7921_phy *phy, bool set_default) return 0; } #endif +int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw, + const struct cfg80211_sar_specs *sar); #endif -- 2.18.0