From patchwork Sun Dec 15 03:56:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11292561 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 AF0B86C1 for ; Sun, 15 Dec 2019 03:56:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B1F12465B for ; Sun, 15 Dec 2019 03:56:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="M6RPoHdB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbfLOD4q (ORCPT ); Sat, 14 Dec 2019 22:56:46 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:59863 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725933AbfLOD4q (ORCPT ); Sat, 14 Dec 2019 22:56:46 -0500 X-UUID: bd32002ec29549f8b1e57599c5ff4c02-20191215 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=94xcQ2Z3dMqXswcxMI8M18CsZNx5V6+VkyJZm38GJdA=; b=M6RPoHdBWCLhl7GGdPO2fAIPyIgHq8iYFcyKkoQDhlSTJ+fbVd3uBqBsUKEtmGArRipAvuYCx2woY9rJ4XRQCoK2RDScr4ToifTnL1foKHzUODPE5W+Ar108oBhQYrGXhvQX/kYac+9xixRTg7LRp7CZU7mceDz89koUmnKLFWo=; X-UUID: bd32002ec29549f8b1e57599c5ff4c02-20191215 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1202441300; Sun, 15 Dec 2019 11:56:37 +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; Sun, 15 Dec 2019 11:56:35 +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; Sun, 15 Dec 2019 11:56:22 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Roy Luo , , , , Ryder Lee , Shayne Chen Subject: [PATCH 2/2] mt76: mt7615: add set_antenna callback Date: Sun, 15 Dec 2019 11:56:32 +0800 Message-ID: <6b3ac6736c0cfa12492f383ec9cfcaad91bfb965.1576381077.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 X-TM-SNTS-SMTP: 57E95DD40047F0123CF19775E0D27F7C3250BF6C281BF99FAF626FD033563F632000: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 --- .../net/wireless/mediatek/mt76/mt7615/main.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index 759a66997c6f..70791544a088 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -48,6 +48,8 @@ static int mt7615_start(struct ieee80211_hw *hw) mt7615_mcu_set_mac_enable(dev, 1, true); } + mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH); + set_bit(MT76_STATE_RUNNING, &phy->mt76->state); if (running) @@ -635,6 +637,33 @@ 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); + mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH); + + mutex_unlock(&dev->mt76.mutex); + + return 0; +} + const struct ieee80211_ops mt7615_ops = { .tx = mt7615_tx, .start = mt7615_start, @@ -659,5 +688,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, };