From patchwork Sun Dec 22 20:11:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11307679 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D61BE921 for ; Sun, 22 Dec 2019 20:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAD22206D3 for ; Sun, 22 Dec 2019 20:11:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="XzBePS2o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbfLVULv (ORCPT ); Sun, 22 Dec 2019 15:11:51 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:12127 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725951AbfLVULv (ORCPT ); Sun, 22 Dec 2019 15:11:51 -0500 X-UUID: c62fb3d6d6864253a7bdd0b2cbb2ac63-20191223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=qwrFGFIz+QsHDpFfg3vjjA8jTU7ruwsFDOyFkQxVOwo=; b=XzBePS2oWDOW/O8HlRnO/pinGEhEHV/Ur8WBdG10D7nscXA9/HQPcIhx+SiTTIa2a1ktxji36EEXUHXsJOSy119x+SW9IxtOW1SCDCYuv3FlGchhq0a6RZFx1hQ/Ejbyucs3Pi7NBJLtFIMIql/P82jXj6t6JV3imQZQvZTdW2Y=; X-UUID: c62fb3d6d6864253a7bdd0b2cbb2ac63-20191223 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 958929746; Mon, 23 Dec 2019 04:11:44 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 23 Dec 2019 04:11:42 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 23 Dec 2019 04:10:52 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: , , , Ryder Lee , Shayne Chen Subject: [PATCH v1 2/2] mt76: mt7615: add set_antenna callback Date: Mon, 23 Dec 2019 04:11:39 +0800 Message-ID: <965287b3917a6cb0cfd2acbf91dbbd0b9db9b085.1577044827.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <9a37e1340cc8c546587d7cf99d6c4d92e12e1a7d.1577044827.git.ryder.lee@mediatek.com> References: <9a37e1340cc8c546587d7cf99d6c4d92e12e1a7d.1577044827.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 8FD17A3244B10A2B92653ADE44844F4B5FF4EAB66C010A873F8A6619B11B88FE2000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add a set_antenna callback to setup per phy tx/rx streams. Signed-off-by: Shayne Chen Signed-off-by: Ryder Lee --- Changes since v1: - remove unnecessary call regard to antenna settings. --- .../net/wireless/mediatek/mt76/mt7615/main.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index 90c4e785a1a3..5b83528f77a0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -637,6 +637,32 @@ mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class) mt7615_mac_set_timing(phy); } +static int +mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) +{ + struct mt7615_dev *dev = mt7615_hw_dev(hw); + struct mt7615_phy *phy = mt7615_hw_phy(hw); + int max_nss = hweight8(hw->wiphy->available_antennas_tx); + bool ext_phy = phy != &dev->phy; + + if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss) + return -EINVAL; + + if ((BIT(hweight8(tx_ant)) - 1) != tx_ant) + tx_ant = BIT(ffs(tx_ant) - 1) - 1; + + mutex_lock(&dev->mt76.mutex); + + phy->mt76->antenna_mask = tx_ant; + phy->chainmask = ext_phy ? tx_ant << 2 : tx_ant; + + mt76_set_stream_caps(&dev->mt76, true); + + mutex_unlock(&dev->mt76.mutex); + + return 0; +} + const struct ieee80211_ops mt7615_ops = { .tx = mt7615_tx, .start = mt7615_start, @@ -661,5 +687,6 @@ const struct ieee80211_ops mt7615_ops = { .channel_switch_beacon = mt7615_channel_switch_beacon, .get_survey = mt76_get_survey, .get_antenna = mt76_get_antenna, + .set_antenna = mt7615_set_antenna, .set_coverage_class = mt7615_set_coverage_class, };