From patchwork Thu Sep 20 09:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10607231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EBF014BD for ; Thu, 20 Sep 2018 09:27:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7F52CC06 for ; Thu, 20 Sep 2018 09:27:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71C2C2CDC1; Thu, 20 Sep 2018 09:27:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E5F512CC06 for ; Thu, 20 Sep 2018 09:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kAIPbTpvyY89UYUeiI+GKfu8AzQxECdDDQNityQCAw8=; b=ZNRoRh9L0XOqnIzxssSGYZ1q2L QPPf3TmwTmBy99WdACGAipB/qXoYH6usgiEGFwYQ/eErWmrul/silmo004x/b+5imH/aOEA+3RdWP R3vUCtzqjVE3m72PA1NLCWYhX58zMKZsXqR/KIR1evlORpljZXmWnGOUQgb/tRD7XGNFfJq6uTaKp Xaek6nziKciwDiHHgsSZGoNT20AcqhBpgbL1EQ0T2UZRyUpdwKBu65ocxdw05dx6hQOoDtx9WHz7H IqqHIqM+RJz8NZswe2mCVaCQep6ar+50BP8D8bKqrJVUNJLVDPtEpFLOUw3fiypEU/5P2jSyeXJOK C/K0dJSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vFN-0000E5-N9; Thu, 20 Sep 2018 09:27:41 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vE3-0007yC-Il for linux-mediatek@bombadil.infradead.org; Thu, 20 Sep 2018 09:26:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vuFTv6Z/gVltTgGVz4g7Vc02rw0v8o+mwmyzPfTpoPw=; b=NIjmhW/IhdfkEup0wKu2nXkrn vaffbUBHGtyMvYzXzGDmPqPRFOcKJNuWLruXyCOP65tyNLDvFS1lSYfUSlXd7I3x19fLAY7ZiHEPD K3M/eh0yviuypMQVLOgPvjSVEryodw/91l59ZwaH5YcEgLtWXmO4Vgd+P+DgXO5t73gfPzgCFbm93 80oqnHu2aVDnAYWvXfGasyvIJ+zU7R1l3lMAnk8N/iv9Ozja1dZKkawxcxAysbeZaMTXWTtmgqUml +/PeieDErzMfVUCxm5mlaFmqB3WLBLJh+2ogh1CT/NAk89nv5EInayRmlS2EhPFMzGp2wcweH0Ys7 rfV0kW2Tg==; Received: from mail-wm1-f68.google.com ([209.85.128.68]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2v13-0000Xh-LR for linux-mediatek@lists.infradead.org; Thu, 20 Sep 2018 09:12:54 +0000 Received: by mail-wm1-f68.google.com with SMTP id r1-v6so978774wmh.0 for ; Thu, 20 Sep 2018 02:12:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vuFTv6Z/gVltTgGVz4g7Vc02rw0v8o+mwmyzPfTpoPw=; b=ZaugutO4kVeC3IVpQwSWK5A5BmQNJYwEaydLXkOphwRevZZYMJjf/dISRnZidBvUmP LFhrY+f+E/UYW5ZbsB5aGg6nkyxnF9js+QpY16Wecqinpr1EyltgOPtA3PeK7y/0rRq3 tBxv5475LO55dTyqLMhD9QH2deQpxayHOjJ5y3Dwxcgc6tLCEbaecG+hnb5DUQZHZRfm OJRoOXH00mFU72Oo2T3lonUfRdxhv2DbaNGyUEDBO8TJ0BJ0lmLImJqvQRQS2iYlC/7p aSwPGqktCv4iZlBYHlhJldfgbFHMHc5MZmw9uPaxOf9ov36J7EXJkNPkdH147EG+M1Hx 6dEA== X-Gm-Message-State: APzg51Cn3mEHoUz5CTfn1pRgH1A49bkHF5hbR+Rm/9qJbCwA6QbEzN+z r2iTLMyltVlnSJc/6jpqhWE5dw== X-Google-Smtp-Source: ANB0VdbiDz50DtNhgsdUUpkhsCRmaMGx+V0xa3FBWBs0CcHhky3kRnDk+XhvTqIRQ15Qt8MnZy/sUQ== X-Received: by 2002:a1c:a8d0:: with SMTP id r199-v6mr1561968wme.97.1537434762256; Thu, 20 Sep 2018 02:12:42 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 34-v6sm35501691wra.20.2018.09.20.02.12.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 02:12:41 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Subject: [PATCH 17/20] mt76: move mt76x2_tssi_enabled in mt76x02_eeprom.h Date: Thu, 20 Sep 2018 11:12:04 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_051253_742109_FFC1266D X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sgruszka@redhat.com, linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Move mt76x2_tssi_enabled and mt76x02_temp_tx_alc_enabled in mt76x02_eeprom.h in order to be reused in mt76x0 driver Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt76x02_eeprom.h | 21 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76x2_eeprom.c | 4 ++-- .../wireless/mediatek/mt76/mt76x2_eeprom.h | 21 ------------------- .../net/wireless/mediatek/mt76/mt76x2_phy.c | 4 ++-- .../net/wireless/mediatek/mt76/mt76x2u_phy.c | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h index 119813960fe7..9339514fb073 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h @@ -162,6 +162,27 @@ mt76x02_eeprom_get(struct mt76_dev *dev, return get_unaligned_le16(dev->eeprom.data + field); } +static inline bool +mt76x02_temp_tx_alc_enabled(struct mt76_dev *dev) +{ + u16 val; + + val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G); + if (!(val & BIT(15))) + return false; + + return mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) & + MT_EE_NIC_CONF_1_TEMP_TX_ALC; +} + +static inline bool +mt76x02_tssi_enabled(struct mt76_dev *dev) +{ + return !mt76x02_temp_tx_alc_enabled(dev) && + (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) & + MT_EE_NIC_CONF_1_TX_ALC_EN); +} + bool mt76x02_ext_pa_enabled(struct mt76_dev *dev, enum nl80211_band band); int mt76x02_get_efuse_data(struct mt76_dev *dev, u16 base, void *buf, int len, enum mt76x02_eeprom_modes mode); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c index d295851cf2f9..21b8fb2e0e28 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c @@ -490,7 +490,7 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, MT_EE_TX_POWER_1_START_2G); } - if (mt76x2_tssi_enabled(dev) || + if (mt76x02_tssi_enabled(&dev->mt76) || !mt76x02_field_valid(t->target_power)) t->target_power = t->chain[0].target_power; @@ -507,7 +507,7 @@ int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t) memset(t, 0, sizeof(*t)); - if (!mt76x2_temp_tx_alc_enabled(dev)) + if (!mt76x02_temp_tx_alc_enabled(&dev->mt76)) return -EINVAL; if (!mt76x02_ext_pa_enabled(&dev->mt76, band)) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h index ad98a52ec69f..650f9564f0f4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h @@ -60,27 +60,6 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t); void mt76x2_read_rx_gain(struct mt76x2_dev *dev); -static inline bool -mt76x2_temp_tx_alc_enabled(struct mt76x2_dev *dev) -{ - u16 val; - - val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_EXT_PA_5G); - if (!(val & BIT(15))) - return false; - - return mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1) & - MT_EE_NIC_CONF_1_TEMP_TX_ALC; -} - -static inline bool -mt76x2_tssi_enabled(struct mt76x2_dev *dev) -{ - return !mt76x2_temp_tx_alc_enabled(dev) && - (mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1) & - MT_EE_NIC_CONF_1_TX_ALC_EN); -} - static inline bool mt76x2_has_ext_lna(struct mt76x2_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c index 3f786596e586..22e66006a5f8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c @@ -25,7 +25,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x2_dev *dev) struct ieee80211_channel *chan = dev->mt76.chandef.chan; u32 flag = 0; - if (!mt76x2_tssi_enabled(dev)) + if (!mt76x02_tssi_enabled(&dev->mt76)) return false; if (mt76x2_channel_silent(dev)) @@ -390,7 +390,7 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev, sizeof(dev->cal.agc_gain_cur)); /* init default values for temp compensation */ - if (mt76x2_tssi_enabled(dev)) { + if (mt76x02_tssi_enabled(&dev->mt76)) { mt76_rmw_field(dev, MT_TX_ALC_CFG_1, MT_TX_ALC_CFG_1_TEMP_COMP, 0x38); mt76_rmw_field(dev, MT_TX_ALC_CFG_2, MT_TX_ALC_CFG_2_TEMP_COMP, diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c index 1cd9b2468ef0..b3ec56d35e7f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c @@ -235,7 +235,7 @@ int mt76x2u_phy_set_channel(struct mt76x2_dev *dev, if (scan) return 0; - if (mt76x2_tssi_enabled(dev)) { + if (mt76x02_tssi_enabled(&dev->mt76)) { /* init default values for temp compensation */ mt76_rmw_field(dev, MT_TX_ALC_CFG_1, MT_TX_ALC_CFG_1_TEMP_COMP, 0x38);