Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp7454lqj; Wed, 10 Apr 2024 02:00:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1C8RLBbN2cWMlAEiw+iRgdgnMvKrjnMp8+fHUQfEHgAzkY/WwM2pMKa0WGQ1igxxn+Y0f9tmts/G70hFZi5H1ctGgSTED2teXgAI4FA== X-Google-Smtp-Source: AGHT+IGF/3S6KxFN4v8jmXrAnygjRLcz3/26Izl70Ls8RZHzo3CBZIhnTNh23RInAY+ZW87Xgb6d X-Received: by 2002:a05:6870:2189:b0:22e:ace7:81b9 with SMTP id l9-20020a056870218900b0022eace781b9mr2132682oae.2.1712739605694; Wed, 10 Apr 2024 02:00:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712739605; cv=pass; d=google.com; s=arc-20160816; b=j+XE/PVIpbD3A62UFn8bC3zEIcDJiy7qlOU8qBkJTV7xMUGEGeA3IR3UKXVETj1S/j E44fCYaf/tPnd9s4d2qq3JxfvxGRA14d8W1XBpeoD2FYx/m3EkSEgeIWmFDEp+FAh2ch b9b21tvzoob7gjCYLjmdSsSeacA1wPVlK90nzHWkIBrnVqbimJIGDSv0wljQ1CcwUUWC 9XkzdMcm44F/xL5J/8mEpEsr5hx1D9TQXToTo6hD/ZIkHM140lrqE+IYzJnLPRk3IQf7 mwVlyYBpu3kS0JafOWuRQOzFcQon3peyxbJkaHSCBLbc9fh5Sb5a3V2Sls1ngPbO3VXj OKpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=PFhJxH4CaslXbdhzI7BUJ/XXbZzgyd0FQyEp/joVvY4=; fh=EDJ3I/TjP7l9SYLlHrkj8ypypm8kNoVWPgLJlYDRkmE=; b=pS0eS9M1n4R7nNZl/buh4M2OgvFWFTHWuMnu5M9n98SbMxXNcOiJ1nMWyjcu6iXhrD 1zJ0ocMu8JDiDtU02k/2JV23KRQsuSYIumfrXoWtO9Ry3ej7be8ELhYF1+hXaqqvTWl/ 0iQiwuaMfd8YidRv8ReOGvhg7EXwGDjzPaxDIxQSLhzhJL8wtj4tnvR3dlLYx6dN4JpO JykJJVpRRMZQqrMUC/wzTLX+H14YE+nZfawnGLryDQKnAzBMONAxPMj5sYQZsMl5rRdJ bX3cABG57piEbe+Gms1J492EUBnu1Wubjs2IAS7rGoqaI+jDQOFhm8U17aWYGUrMlu2f UPdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=PsKIy8AU; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-wireless+bounces-6078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y13-20020a056a00180d00b006eaa98c88b5si10768709pfa.64.2024.04.10.02.00.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 02:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=PsKIy8AU; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-wireless+bounces-6078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 363562840F0 for ; Wed, 10 Apr 2024 09:00:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DFBE13D8B2; Wed, 10 Apr 2024 09:00:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="PsKIy8AU" X-Original-To: linux-wireless@vger.kernel.org Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE70713D297 for ; Wed, 10 Apr 2024 08:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712739600; cv=none; b=pGSKS+97XESoL5yxm32/Agb2HJ01Ep5r0k10T0HBHXeEdSx6P6ox6DkmebheouNNrZebE/ffTwzdBKF/9PSBR+eDVc9R+osFOrSpf4PWHPSQlA0fjAE5jZuctiHOYeeC9klOgZBVs+y6qeatCb7PG1tRCP9I3sy/Ztxj9R5O/xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712739600; c=relaxed/simple; bh=xouM1eXfq2lxMlqjLMfqWQoXflTAbGf6QmEbhv7Bhzw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=KjvIHEFluIBKiLZ2BJ6pWz/y62/7sXFZj/ZKj057qHiuVoA/jBpVNYL66IlbB84yE6fnBS1B9AdZOA2BlEGHzexqOatIawOZIz4uxyGhqc1ZYEcVBJ1q5BaCDtBOHsTrltiBvQzxVwx+gWP3Ac49UcoUXtvTLOBNg1raR92XVx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=PsKIy8AU; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: b1dc9bb2f71811ee935d6952f98a51a9-20240410 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=PFhJxH4CaslXbdhzI7BUJ/XXbZzgyd0FQyEp/joVvY4=; b=PsKIy8AUTl3gSNLi42+KIlLHD+S/jqE0ZtoFhuhQT0ILFklSxd0CEWORlX+L5yxc3GHAqXg+F5nGrbUk+asqXxTWaDDNaZbiaCos9dK9OZxFdX/d0RD3LqWOa/E6MOWbTeGMhVo/v5j3GKb81MVyActRZjwe1MfIxVs7261gkVk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:05ba95f5-7c3e-42cf-84b3-2d6f53c7f804,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6f543d0,CLOUDID:06cabefa-ed05-4274-9204-014369d201e8,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: b1dc9bb2f71811ee935d6952f98a51a9-20240410 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1337047986; Wed, 10 Apr 2024 16:59:53 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 10 Apr 2024 16:59:51 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 10 Apr 2024 16:59:51 +0800 From: Quan Zhou To: Quan Zhou , Felix Fietkau , Lorenzo Bianconi CC: Sean Wang , Deren Wu , Ryder Lee , Shayne Chen , linux-wireless , linux-mediatek , Shengxi Xu , Hao Zhang Subject: [PATCH] wifi: mt76: mt7921e: add LED control support Date: Wed, 10 Apr 2024 16:58:51 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N From: Hao Zhang Introduce wifi LED switch control, add flow to Control a wifi gpio pin based on the status of WIFI radio, if the pin is connected to an LED, the LED will indicate the status of the WiFi radio. Signed-off-by: Hao Zhang Co-developed-by: Quan Zhou Signed-off-by: Quan Zhou --- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + .../net/wireless/mediatek/mt76/mt7921/main.c | 26 ++++++++++++++++++- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 14 ++++++++++ .../wireless/mediatek/mt76/mt7921/mt7921.h | 5 ++++ .../net/wireless/mediatek/mt76/mt7921/pci.c | 8 +++++- 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 836cc4d5b1d2..4c2de556dee1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -1189,6 +1189,7 @@ enum { MCU_EXT_CMD_EFUSE_ACCESS = 0x01, MCU_EXT_CMD_RF_REG_ACCESS = 0x02, MCU_EXT_CMD_RF_TEST = 0x04, + MCU_EXT_CMD_ID_RADIO_ON_OFF_CTRL = 0x05, MCU_EXT_CMD_PM_STATE_CTRL = 0x07, MCU_EXT_CMD_CHANNEL_SWITCH = 0x08, MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11, diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index ca36de34171b..ac2174b345cd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -242,6 +242,15 @@ int __mt7921_start(struct mt792x_phy *phy) ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, MT792x_WATCHDOG_TIME); + if (mt76_is_mmio(mphy->dev)) { + err = mt7921_mcu_radio_led_ctrl(phy->dev, EXT_CMD_RADIO_LED_CTRL_ENABLE); + if (err) + return err; + + err = mt7921_mcu_radio_led_ctrl(phy->dev, EXT_CMD_RADIO_ON_LED); + if (err) + return err; + } return 0; } @@ -259,6 +268,21 @@ static int mt7921_start(struct ieee80211_hw *hw) return err; } +static void mt7921_stop(struct ieee80211_hw *hw) +{ + struct mt792x_dev *dev = mt792x_hw_dev(hw); + int err = 0; + + mt792x_mutex_acquire(dev); + if (mt76_is_mmio(&dev->mt76)) + err = mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_OFF_LED); + mt792x_mutex_release(dev); + if (err) + return; + + mt792x_stop(hw); +} + static int mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -1372,7 +1396,7 @@ static void mt7921_mgd_complete_tx(struct ieee80211_hw *hw, const struct ieee80211_ops mt7921_ops = { .tx = mt792x_tx, .start = mt7921_start, - .stop = mt792x_stop, + .stop = mt7921_stop, .add_interface = mt7921_add_interface, .remove_interface = mt792x_remove_interface, .config = mt7921_config, diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 8b4ce32a2cd1..2ebf0ffe78d5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -606,6 +606,20 @@ int mt7921_run_firmware(struct mt792x_dev *dev) } EXPORT_SYMBOL_GPL(mt7921_run_firmware); +int mt7921_mcu_radio_led_ctrl(struct mt792x_dev *dev, u8 value) +{ + struct { + u8 ctrlid; + u8 rsv[3]; + } __packed req = { + .ctrlid = value, + }; + + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ID_RADIO_ON_OFF_CTRL), + &req, sizeof(req), false); +} +EXPORT_SYMBOL_GPL(mt7921_mcu_radio_led_ctrl); + int mt7921_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif) { struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 3016636d18c6..07023eb9e5b5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -27,6 +27,10 @@ #define MCU_UNI_EVENT_ROC 0x27 #define MCU_UNI_EVENT_CLC 0x80 +#define EXT_CMD_RADIO_LED_CTRL_ENABLE 0x1 +#define EXT_CMD_RADIO_ON_LED 0x2 +#define EXT_CMD_RADIO_OFF_LED 0x3 + enum { UNI_ROC_ACQUIRE, UNI_ROC_ABORT, @@ -196,6 +200,7 @@ int mt7921_mcu_fw_log_2_host(struct mt792x_dev *dev, u8 ctrl); void mt7921_mcu_rx_event(struct mt792x_dev *dev, struct sk_buff *skb); int mt7921_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif, u8 bit_op, u32 bit_map); +int mt7921_mcu_radio_led_ctrl(struct mt792x_dev *dev, u8 value); static inline u32 mt7921_reg_map_l1(struct mt792x_dev *dev, u32 addr) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 0b69b225bc16..f768e9389ac6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -427,6 +427,10 @@ static int mt7921_pci_suspend(struct device *device) wait_event_timeout(dev->wait, !dev->regd_in_progress, 5 * HZ); + err = mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_OFF_LED); + if (err < 0) + goto restore_suspend; + err = mt76_connac_mcu_set_hif_suspend(mdev, true); if (err) goto restore_suspend; @@ -525,9 +529,11 @@ static int mt7921_pci_resume(struct device *device) mt76_connac_mcu_set_deep_sleep(&dev->mt76, false); err = mt76_connac_mcu_set_hif_suspend(mdev, false); + if (err < 0) + goto failed; mt7921_regd_update(dev); - + err = mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_ON_LED); failed: pm->suspended = false; -- 2.18.0