Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1030645lqb; Wed, 17 Apr 2024 19:51:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUf6PH3u6xMGwuDII35kpE6RoMmCp/7bZOqZRxlNLeDoRDVr2YckXCXv5qj9ddDzEKetugdCMfCKz2lk6CpJNH9aEPp00BCKNRt2LzTCw== X-Google-Smtp-Source: AGHT+IEWQxGAdyH9E6Xhj4dFW1kJnSHEngZjRJPgdFVgD9YGqMMRiJcJo7giWa9iOE5EmD4B4li2 X-Received: by 2002:a17:907:7249:b0:a55:6f2c:d7ca with SMTP id ds9-20020a170907724900b00a556f2cd7camr491294ejc.32.1713408663574; Wed, 17 Apr 2024 19:51:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713408663; cv=pass; d=google.com; s=arc-20160816; b=iBQopo3RqJsimvkXq5w9Pp585Ngt8tGdA/q91k0hLdPBnE60nb6WgHHRwHM6n3qmTU grdDRNa8vC+IgYCBK3UJw88jnvmH3ryL60pGMVarfXuTJ9pZiESirS2C5mzmoicolGmb k6m9HDNUXsAJKiBzUfSdtvfcuy7PQK2NzvU6bX63t9gmfTCuPk6R63ewctdkYPT6VBbL u7FzWDehkHeLEdhUZC0WciKobwGDX3nk8IpkrFGErcNkTpqfTCiX3npbZshv0yeiPhA6 QO3ghjAI+GFozwkhJzuZD7gABRPdB9hpNqcYpvmJR4HH34qXlseOYPhzPjPk2lEmFxpB wrZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=1TpMc0b3pyWyJuGgY3DBaNK0zVX38FZH6XbZpO+2+qU=; fh=ZEo05oIhO+Vgblp9n5Lc5XgqBpqJUXDOlR5wpd77+LU=; b=I9iNqpe2T5mp2z1B+NbHAvX9EEekTu1g1lo6K1+UTMM9jyTauCbC/U83zBq8P1NAF8 yRfVnSzvfYRn1P8H8v+7lgmtN2ytm7N3WSrwRCXnjLJ755oiy/UhKMCgdrAib1HgvbWI mc4jkVdaeDKmRj62khPJDvIXnT3MydGswi2x70uUzv9uq/ac+8UJT38uq71L96VjU39N +NbnUHK7lbR2fKj80q8ChClBZ9Ec7Y3fgpu84EYCdXnP6QLZ30mm/ZmIlDUN4HelkWgh ncGb/NQ3qHs+Smg6VWbAMni/RIguQZOqkGBfzZyCCW/GG+SvkmrrdE96eYHW1lodCozN Ykwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="gJS8EQ/B"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-6488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6488-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o8-20020a17090611c800b00a522cd67dc6si284643eja.954.2024.04.17.19.51.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 19:51:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="gJS8EQ/B"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-6488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6488-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 27FF41F21241 for ; Thu, 18 Apr 2024 02:51:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 419C8286AF; Thu, 18 Apr 2024 02:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gJS8EQ/B" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1C6D063D5 for ; Thu, 18 Apr 2024 02:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713408659; cv=none; b=vE7cPVzJv4GRtYoUx7XJigJugkCR7qvX54pixpBuXcLsSNTfqUaO6Y0+2wtTTRSEvU7wfwSTjAAbhQTQaeo3Cgj+z2w8ffld8DLYaTpcnvnQFmvpceMpp9S4DOuejxSyz0/R0sxXZ4LtVqIjf/fq1e6+nH+YVWaCDw4Dk5VMV+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713408659; c=relaxed/simple; bh=3Rc6752rBiGPr/0xv5ZCsFWyNqVQsj4KsbGFchAYx5g=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=huqeADIOKKx+svgnlbX1R63GGOSdySx7D2OUGWC5xuWlUpi/qeAPzbMLe/ggZCxQN6Bgie3gMvjgqzS577ruBi35jLHLtWeevnUEwTpsAVh6Fj6ybAyGH2DD7U8uA5oaAAQmKuStiwmrl3pFJqrHqvSz8/QH2pWK1whigiU2PCA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gJS8EQ/B; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E485C072AA for ; Thu, 18 Apr 2024 02:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713408658; bh=3Rc6752rBiGPr/0xv5ZCsFWyNqVQsj4KsbGFchAYx5g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gJS8EQ/BmnbFiUwfoXAjRwo6hApEJnsqydF038OLMNXnK1JEPEjuL4hQ6elXgffSC phxPICNCuuqItPnFQrez7sQP6gInIEDv9TAJZheGjrCuJr/MZszmm0V7l5x+aZFZCr DieYyttO4OBffTnznTiGXdmNhdmdb18JoOoN2hQhAcVOAqSQFWqRUapmsNoG7oCgEC d8TFvlOWd1ZnhfaNxgeYAtCxSazk71jUI2274n8fF5BbPLO79z7m4gvngx3cx5CeS9 JPbkL2ThM2PpR9bxgST0PvmY6pXF8eyDoFC7G/Tbgdl1KxwZqwXMk/uScXlzPhY0DP dvw3z1hkenZkw== Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2dac628f08fso1098021fa.3 for ; Wed, 17 Apr 2024 19:50:58 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXD4irMOjGxxV5tvUoY+JCIjcA8tskrJJ8iebgRtFW32O3hNnncyS/78jEPkJNEQecEERynr2SXyGSlQ4fOSB523ZZy5TGL0P/xJFXfOBU= X-Gm-Message-State: AOJu0YxKzX/mofwU6NpSPU7Y1LKAQKOWNxulkJkEI3sryJBXRYyXaCcC PY10XanMBKFKZ9MaiZjpHZ7qhrnifFgyMHv05Vr/X2vz6gFgEwlzdex5hPQgO1oOQfHHKFtjYGr 7VYdSj2FEViAn0MKzjmD6oHSmL+Y= X-Received: by 2002:ac2:599d:0:b0:516:d6b5:7caf with SMTP id w29-20020ac2599d000000b00516d6b57cafmr514839lfn.6.1713408656259; Wed, 17 Apr 2024 19:50:56 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <608cc2bb1c10c2f53a6bf26711bf49fe2c491e59.1712806947.git.quan.zhou@mediatek.com> <37ab8a32893ea9a1cbc33b6dae26b57127ea4e16.camel@mediatek.com> In-Reply-To: <37ab8a32893ea9a1cbc33b6dae26b57127ea4e16.camel@mediatek.com> From: Sean Wang Date: Wed, 17 Apr 2024 19:50:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] wifi: mt76: mt7921e: add LED control support To: =?UTF-8?B?UXVhbiBaaG91ICjlkajlhagp?= Cc: "linux-mediatek@lists.infradead.org" , =?UTF-8?B?U2hlbmd4aSBYdSAo5b6Q6IOc5ZacKQ==?= , =?UTF-8?B?RGVyZW4gV3UgKOatpuW+t+S7gSk=?= , =?UTF-8?B?U2hheW5lIENoZW4gKOmZs+i7kuS4nik=?= , "nbd@nbd.name" , "lorenzo@kernel.org" , Sean Wang , =?UTF-8?B?SGFvIFpoYW5nICjlvKDmtakp?= , Ryder Lee , "linux-wireless@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 17, 2024 at 6:43=E2=80=AFPM Quan Zhou (=E5=91=A8=E5=85=A8) wrote: > > On Wed, 2024-04-17 at 15:06 -0700, Sean Wang wrote: > > > > External email : Please do not click links or open attachments until > > you have verified the sender or the content. > > HI Quan, > > > > On Wed, Apr 10, 2024 at 11:00=E2=80=AFPM Quan Zhou > > wrote: > > > > > > 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 > > > --- > > > v2: > > > fix to avoid wake device when Hardware interface not pcie > > > --- > > > .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + > > > .../net/wireless/mediatek/mt76/mt7921/main.c | 27 > > ++++++++++++++++++- > > > .../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, 53 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 =3D 0x01, > > > MCU_EXT_CMD_RF_REG_ACCESS =3D 0x02, > > > MCU_EXT_CMD_RF_TEST =3D 0x04, > > > + MCU_EXT_CMD_ID_RADIO_ON_OFF_CTRL =3D 0x05, > > > MCU_EXT_CMD_PM_STATE_CTRL =3D 0x07, > > > MCU_EXT_CMD_CHANNEL_SWITCH =3D 0x08, > > > MCU_EXT_CMD_SET_TX_POWER_CTRL =3D 0x11, > > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c > > b/drivers/net/wireless/mediatek/mt76/mt7921/main.c > > > index ca36de34171b..ea6a113b7b36 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)) { > > > > I guess the led control MCU command is not limited to PCIe devices, > > they should be able to be extended even on MT7921 USB and SDIO > > devices, right ? if so, I think we can drop the MMIO limitation > > condition to support more scenarios and to make it easier to > > understand. > > > Hi Sean, > > This software flow involves chip GPIO control and is related to the > module's circuit design. Only the PCIe module can provide support for > this, so can't drop. Hi Quan, Thanks for clearing that up quickly. I guess we can add it just for MT7921E. I have another question: Will the new command you added work with older firmware, or is it made only for the most recent firmware? I'm worried it might not be compatible with the older MT7921 firmware. Sean > > > > + err =3D mt7921_mcu_radio_led_ctrl(phy->dev, > > EXT_CMD_RADIO_LED_CTRL_ENABLE); > > > + if (err) > > > + return err; > > > + > > > + err =3D mt7921_mcu_radio_led_ctrl(phy->dev, > > EXT_CMD_RADIO_ON_LED); > > > + if (err) > > > + return err; > > > + } > > > > > > return 0; > > > } > > > @@ -259,6 +268,22 @@ static int mt7921_start(struct ieee80211_hw > > *hw) > > > return err; > > > } > > > > > > +static void mt7921_stop(struct ieee80211_hw *hw) > > > +{ > > > + struct mt792x_dev *dev =3D mt792x_hw_dev(hw); > > > + int err =3D 0; > > > + > > > + if (mt76_is_mmio(&dev->mt76)) { > > > + mt792x_mutex_acquire(dev); > > > + err =3D 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 +1397,7 @@ static void mt7921_mgd_complete_tx(struct > > ieee80211_hw *hw, > > > const struct ieee80211_ops mt7921_ops =3D { > > > .tx =3D mt792x_tx, > > > .start =3D mt7921_start, > > > - .stop =3D mt792x_stop, > > > + .stop =3D mt7921_stop, > > > .add_interface =3D mt7921_add_interface, > > > .remove_interface =3D mt792x_remove_interface, > > > .config =3D 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 =3D { > > > + .ctrlid =3D 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 =3D (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 =3D mt7921_mcu_radio_led_ctrl(dev, > > EXT_CMD_RADIO_OFF_LED); > > > + if (err < 0) > > > + goto restore_suspend; > > > + > > > err =3D 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 =3D mt76_connac_mcu_set_hif_suspend(mdev, false); > > > + if (err < 0) > > > + goto failed; > > > > > > mt7921_regd_update(dev); > > > - > > > + err =3D mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_ON_LED); > > > failed: > > > pm->suspended =3D false; > > > > > > -- > > > 2.18.0 > > > > > >