From patchwork Fri Sep 28 11:39:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10619825 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 27ED515A6 for ; Fri, 28 Sep 2018 11:39:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B51C2B2BD for ; Fri, 28 Sep 2018 11:39:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FEF92B2DA; Fri, 28 Sep 2018 11:39:44 +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 B2EC72B2BD for ; Fri, 28 Sep 2018 11:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729619AbeI1SDE (ORCPT ); Fri, 28 Sep 2018 14:03:04 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44890 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729605AbeI1SDB (ORCPT ); Fri, 28 Sep 2018 14:03:01 -0400 Received: by mail-wr1-f67.google.com with SMTP id v16-v6so6004931wro.11 for ; Fri, 28 Sep 2018 04:39:39 -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=+dabkHV/l4Ov5wCGLmto4adKjab05FRT0J/vq2PsDyM=; b=clhnnD9oBdJEuwV2VirzSHoUi8mESZMXaZTwBLwFeXZL3w57IcJWLPBOqjE9HcI+wg QjMoXVzaeNprvKd74UkG5drAMPbFqvAjST2PfVXpbAsiYXwigXMHye/uUFdZ+og5v8Ob 3bnU0cxfm2AfccsmZLZrvcf+5cBLb+Kn49awkHiAh0Diu/+ke5x1Rb00HM7TyJTWJPLE FlEmBZgvXPrIdP98qHP1MIrnPZtIhX88Y8fd68SpGaOXan2zKUX4uzUumtSrglqAO5vN 9Kpy4kBg1f3M16HraqsISu7ISRDvk4gzPgMzBNNMVkc3Ms8oKPgcG+axv8kqgu6gGLDr gDZQ== X-Gm-Message-State: ABuFfojKgw0GqlxEwtZSFYsYQMOMExPZtsOpke/CWRnEQsH++rqsNvLH 4iYitTerA6WiZULxnq47yZx/Ii2vv7U= X-Google-Smtp-Source: ACcGV622VYnecSS11P0KDY1imzgZafxISGqmE47zP9wHoXG6gtbEqT5/UtkH1sLu6XweJloFlPn4dw== X-Received: by 2002:adf:f1ce:: with SMTP id z14-v6mr2381758wro.214.1538134778431; Fri, 28 Sep 2018 04:39:38 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id s10-v6sm2395655wmd.22.2018.09.28.04.39.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 04:39:37 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH v3 22/24] mt76x0: pci: add mt76x0e_{start/stop} callbacks Date: Fri, 28 Sep 2018 13:39:05 +0200 Message-Id: <10f7d46687d8c7a1bffa5fd72ddc4a6b30a3dd40.1538134522.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 Introduce mt76x0e_start and mt76x0e_stop mac80211 callbacks to start/stop device mac opening/closing the netdevice Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/pci.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c index 8c020aaf1f0c..876291dd3c1e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c @@ -25,11 +25,45 @@ static int mt76x0e_start(struct ieee80211_hw *hw) { + struct mt76x0_dev *dev = hw->priv; + + mutex_lock(&dev->mt76.mutex); + + mt76x02_mac_start(&dev->mt76); + ieee80211_queue_delayed_work(dev->mt76.hw, &dev->mac_work, + MT_CALIBRATE_INTERVAL); + ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work, + MT_CALIBRATE_INTERVAL); + set_bit(MT76_STATE_RUNNING, &dev->mt76.state); + + mutex_unlock(&dev->mt76.mutex); + return 0; } static void mt76x0e_stop(struct ieee80211_hw *hw) { + struct mt76x0_dev *dev = hw->priv; + + mutex_lock(&dev->mt76.mutex); + + clear_bit(MT76_STATE_RUNNING, &dev->mt76.state); + cancel_delayed_work_sync(&dev->cal_work); + cancel_delayed_work_sync(&dev->mac_work); + + if (!mt76_poll(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_TX_DMA_BUSY, + 0, 1000)) + dev_warn(dev->mt76.dev, "TX DMA did not stop\n"); + mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_TX_DMA_EN); + + mt76x0_mac_stop(dev); + + if (!mt76_poll(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_RX_DMA_BUSY, + 0, 1000)) + dev_warn(dev->mt76.dev, "TX DMA did not stop\n"); + mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_RX_DMA_EN); + + mutex_unlock(&dev->mt76.mutex); } static const struct ieee80211_ops mt76x0e_ops = {