From patchwork Sun Sep 9 20:32:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10593425 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 AF82F13AC for ; Sun, 9 Sep 2018 20:33:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0A9C28451 for ; Sun, 9 Sep 2018 20:33:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9530C28528; Sun, 9 Sep 2018 20:33:00 +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 3226F28451 for ; Sun, 9 Sep 2018 20:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726782AbeIJBXv (ORCPT ); Sun, 9 Sep 2018 21:23:51 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37206 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbeIJBXv (ORCPT ); Sun, 9 Sep 2018 21:23:51 -0400 Received: by mail-wr1-f67.google.com with SMTP id u12-v6so19720040wrr.4 for ; Sun, 09 Sep 2018 13:32:58 -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; bh=crkCn7bqp1KCyDXSeYIueIjOUnjLFpM2W4hbwhPBncg=; b=rDpV//pvCXcV8Z4ycvyDC8hYImUa8uyWLLMAx54sCYeoKh8+kXc9TEA74bN1ZmeD4B 5VC18pskrOy+RnBv8cC8uSGLyGGe0hVLu9k5GYK10GeCeTcENzmIWtCfU1vzMXkeCE4O QDsSc7JsVtSpFAlAYsfeEN8vG1alhwhy7arxX+a1rpb3gDl206yRLO8k4ZjvGndbb1eP VjtPUfw+Q2DcD650pV/R96I95TRlcPZ5rbRTDYSXlqeIsR2CbuUfd6lHqJ7VFKd0Sr0z CJ7gPQ5umr6bmENNXbqmDenqEckRCf6+u8V8vBfi+ZB6ULm64TK0PfuHnDPFILzLMecu JpIA== X-Gm-Message-State: APzg51AzXVdaTW0xim8Lw9lu8KBbUUBvEkOsavdKFhPnlBFDFCqzDQ0n apGZoXEcjICaam4hrEAeKC26Mw== X-Google-Smtp-Source: ANB0VdYpGJ37nwRY3VlB+xhmrBAb7DMCTuFMUXx74JnD9x11c3XVtft08zxoiiGgAd4NVbRv+O1Uvg== X-Received: by 2002:adf:9306:: with SMTP id 6-v6mr13369526wro.211.1536525177585; Sun, 09 Sep 2018 13:32:57 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id y184-v6sm13652006wmg.17.2018.09.09.13.32.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 13:32:57 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH 04/11] mt76: add rd_rp and wr_rp to bus_ops/mcu_ops Date: Sun, 9 Sep 2018 22:32:39 +0200 Message-Id: <20180909203246.21608-5-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 From: Stanislaw Gruszka Add callbacks for reading and writing reg pairs tables. Signed-off-by: Stanislaw Gruszka Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 20 +++++++++++++++----- drivers/net/wireless/mediatek/mt76/usb.c | 2 ++ drivers/net/wireless/mediatek/mt76/usb_mcu.c | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 0443edcdbeff..b0df3f85ccd1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -33,12 +33,21 @@ struct mt76_dev; struct mt76_wcid; +struct mt76_reg_pair { + u32 reg; + u32 value; +}; + struct mt76_bus_ops { u32 (*rr)(struct mt76_dev *dev, u32 offset); void (*wr)(struct mt76_dev *dev, u32 offset, u32 val); u32 (*rmw)(struct mt76_dev *dev, u32 offset, u32 mask, u32 val); void (*copy)(struct mt76_dev *dev, u32 offset, const void *data, int len); + int (*wr_rp)(struct mt76_dev *dev, u32 base, + const struct mt76_reg_pair *rp, int len); + int (*rd_rp)(struct mt76_dev *dev, u32 base, + struct mt76_reg_pair *rp, int len); }; enum mt76_txq_id { @@ -53,11 +62,6 @@ enum mt76_txq_id { __MT_TXQ_MAX }; -struct mt76_reg_pair { - u32 reg; - u32 value; -}; - enum mt76_rxq_id { MT_RXQ_MAIN, MT_RXQ_MCU, @@ -122,6 +126,10 @@ struct mt76_mcu_ops { struct sk_buff *(*mcu_msg_alloc)(const void *data, int len); int (*mcu_send_msg)(struct mt76_dev *dev, struct sk_buff *skb, int cmd, bool wait_resp); + int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base, + const struct mt76_reg_pair *rp, int len); + int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base, + struct mt76_reg_pair *rp, int len); }; struct mt76_queue_ops { @@ -441,6 +449,8 @@ struct mt76_rx_status { #define mt76_wr(dev, ...) (dev)->mt76.bus->wr(&((dev)->mt76), __VA_ARGS__) #define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__) #define mt76_wr_copy(dev, ...) (dev)->mt76.bus->copy(&((dev)->mt76), __VA_ARGS__) +#define mt76_wr_rp(dev, ...) (dev)->mt76.bus->wr_rp(&((dev)->mt76), __VA_ARGS__) +#define mt76_rd_rp(dev, ...) (dev)->mt76.bus->rd_rp(&((dev)->mt76), __VA_ARGS__) #define mt76_mcu_msg_alloc(dev, ...) (dev)->mt76.mcu_ops->mcu_msg_alloc(__VA_ARGS__) #define mt76_mcu_send_msg(dev, ...) (dev)->mt76.mcu_ops->mcu_send_msg(&((dev)->mt76), __VA_ARGS__) diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index 93cda21aa50c..aca6dcfe7a98 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -876,6 +876,8 @@ int mt76u_init(struct mt76_dev *dev, .wr = mt76u_wr, .rmw = mt76u_rmw, .copy = mt76u_copy, + .wr_rp = mt76u_wr_rp, + .rd_rp = mt76u_rd_rp, }; struct mt76_usb *usb = &dev->usb; diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c index 622d7d6da32e..7cbc02d8ec35 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -381,6 +381,8 @@ void mt76u_init_mcu_ops(struct mt76_dev *dev) static const struct mt76_mcu_ops mt76u_mcu_ops = { .mcu_msg_alloc = mt76u_mcu_msg_alloc, .mcu_send_msg = mt76u_mcu_send_msg, + .mcu_wr_rp = mt76u_mcu_wr_rp, + .mcu_rd_rp = mt76u_mcu_rd_rp, }; dev->mcu_ops = &mt76u_mcu_ops;