From patchwork Tue Jul 31 08:09: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: 10550377 X-Patchwork-Delegate: kvalo@adurom.com 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 72E8415E2 for ; Tue, 31 Jul 2018 08:09:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 664FA2A20E for ; Tue, 31 Jul 2018 08:09:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B2712A38B; Tue, 31 Jul 2018 08:09:31 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C59D62A364 for ; Tue, 31 Jul 2018 08:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbeGaJsh (ORCPT ); Tue, 31 Jul 2018 05:48:37 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37190 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbeGaJsg (ORCPT ); Tue, 31 Jul 2018 05:48:36 -0400 Received: by mail-wm0-f66.google.com with SMTP id n11-v6so2086794wmc.2 for ; Tue, 31 Jul 2018 01:09:28 -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=N3v2XVsadKPJ5x6KaFmllJAvTQgIojlWmhyP1tBYOLA=; b=cQ7zELsk45Ssi7HM44YoFo8wfDpEiJ+24OPxoIJsbwwnzfxXzcBWl066pud2GB4Hek EQcs7bGJqKI+FdfQBPkBPp46l44O71uQlQkQai2Acl7D+jam8oDkIINLxxQ53AJD2MAH WyLihg2gbxKlND9x/CELzu7LTYlLYBAeGxmADqNH+HDCZn62LyDPWFqsT5L7VC1ufAzr yvV7EzayjuvURB9o2EJkCAbIBfLP5f6odeY/psmAcucklSuBnti58dGGh3VAftCudzYQ GWLwS9bY2ct88oi/NY/Ft/+sd3IaetWuc0Vc2tTj+MOBwGVQgBfHqOXNbpYvqEoin2rN Bajw== X-Gm-Message-State: AOUpUlFU+D0oN96NXRfrUpUkCU3iKRMI8bIGlGqo0NbHEuh282gf6ft4 +0iLt8vPiWTzNNfFG9rQrSxD8g== X-Google-Smtp-Source: AAOMgpcYb0jBcPoGnGKwKKNWSyfGUgiQiT2XKF6yhaymO/fYSVBzZ2XMfm1xMKsftKcr71ZO7gMWrw== X-Received: by 2002:a1c:4c0e:: with SMTP id z14-v6mr1642322wmf.89.1533024567393; Tue, 31 Jul 2018 01:09:27 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id o4-v6sm1501051wmo.20.2018.07.31.01.09.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 01:09:26 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com Subject: [PATCH v2 03/19] mt76x2: move utility routines in mt76x2.h Date: Tue, 31 Jul 2018 10:09:04 +0200 Message-Id: <4d02242a3df4acdf74bf1ddfab097ba5f9f63804.1533023328.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to reuse them supporting mt76x2u based devices, move mt76x2_wait_for_mac, wait_for_wpdma and mt76x2_channel_silent in mt76x2.h Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x2.h | 40 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt76x2_init.c | 28 ------------- .../net/wireless/mediatek/mt76/mt76x2_phy.c | 9 ----- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2.h index 40e57073923e..e9d9e8228e89 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2.h @@ -159,6 +159,23 @@ struct mt76x2_sta { int inactive_count; }; +static inline bool mt76x2_wait_for_mac(struct mt76x2_dev *dev) +{ + int i; + + for (i = 0; i < 500; i++) { + switch (mt76_rr(dev, MT_MAC_CSR0)) { + case 0: + case ~0: + break; + default: + return true; + } + usleep_range(5000, 10000); + } + return false; +} + static inline bool is_mt7612(struct mt76x2_dev *dev) { return mt76_chip(&dev->mt76) == 0x7612; @@ -166,6 +183,14 @@ static inline bool is_mt7612(struct mt76x2_dev *dev) void mt76x2_set_irq_mask(struct mt76x2_dev *dev, u32 clear, u32 set); +static inline bool mt76x2_channel_silent(struct mt76x2_dev *dev) +{ + struct ieee80211_channel *chan = dev->mt76.chandef.chan; + + return ((chan->flags & IEEE80211_CHAN_RADAR) && + chan->dfs_state != NL80211_DFS_AVAILABLE); +} + static inline void mt76x2_irq_enable(struct mt76x2_dev *dev, u32 mask) { mt76x2_set_irq_mask(dev, 0, mask); @@ -176,6 +201,21 @@ static inline void mt76x2_irq_disable(struct mt76x2_dev *dev, u32 mask) mt76x2_set_irq_mask(dev, mask, 0); } +static inline bool mt76x2_wait_for_bbp(struct mt76x2_dev *dev) +{ + return mt76_poll_msec(dev, MT_MAC_STATUS, + MT_MAC_STATUS_TX | MT_MAC_STATUS_RX, + 0, 100); +} + +static inline bool wait_for_wpdma(struct mt76x2_dev *dev) +{ + return mt76_poll(dev, MT_WPDMA_GLO_CFG, + MT_WPDMA_GLO_CFG_TX_DMA_BUSY | + MT_WPDMA_GLO_CFG_RX_DMA_BUSY, + 0, 1000); +} + extern const struct ieee80211_ops mt76x2_ops; struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2_init.c index 8ab9788464e8..347cccfc74bb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_init.c @@ -24,34 +24,6 @@ struct mt76x2_reg_pair { u32 value; }; -static bool -mt76x2_wait_for_mac(struct mt76x2_dev *dev) -{ - int i; - - for (i = 0; i < 500; i++) { - switch (mt76_rr(dev, MT_MAC_CSR0)) { - case 0: - case ~0: - break; - default: - return true; - } - usleep_range(5000, 10000); - } - - return false; -} - -static bool -wait_for_wpdma(struct mt76x2_dev *dev) -{ - return mt76_poll(dev, MT_WPDMA_GLO_CFG, - MT_WPDMA_GLO_CFG_TX_DMA_BUSY | - MT_WPDMA_GLO_CFG_RX_DMA_BUSY, - 0, 1000); -} - static void mt76x2_mac_pbf_init(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 20ffa6a40d39..9a7b50f0005d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c @@ -176,15 +176,6 @@ void mt76x2_phy_set_txpower(struct mt76x2_dev *dev) mt76x2_tx_power_mask(t.ht[6], t.vht[8], t.vht[8], 0)); } -static bool -mt76x2_channel_silent(struct mt76x2_dev *dev) -{ - struct ieee80211_channel *chan = dev->mt76.chandef.chan; - - return ((chan->flags & IEEE80211_CHAN_RADAR) && - chan->dfs_state != NL80211_DFS_AVAILABLE); -} - static bool mt76x2_phy_tssi_init_cal(struct mt76x2_dev *dev) {