From nobody Thu Apr 9 05:47:44 2026 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC1B23B6357 for ; Wed, 11 Mar 2026 07:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773215585; cv=none; b=d1NMxbscWLNLn7xkau02e/PwshNY3CLt8cqCPCf/vtJUycwO5b6lOxPdUfeek8s0fuNGNh7morDv99SlHo3tI//KuKAUZSUInIEo3sGgfbN631lXG9sGU3E+tS7IrXDU9e5N0/GZbtmk1cFq9zmqjIfQMYMqKf984EEhq8bm2tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773215585; c=relaxed/simple; bh=3GwCyYWj3K19Ko8HJQLif1XyyerN0eopidhctEM5+gM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ToGZtl600laoAtV8r76BgTM7r6W+q5/rxiv1blYcfRCYe12bj4PPqaZZs1EqYeUpfJRRtr8a3RNF0HtjWW8dohgzxTQmsq1S3K+gYkCYHq/BqFTU9vmKEaAjj3d+F1lnmKFE4EnI/c5QhzHQBAUFGAnllKEMeDuZQVsU3SdBW18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=fc7tsK4k; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fc7tsK4k" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-3598e065d8dso4932013a91.2 for ; Wed, 11 Mar 2026 00:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1773215581; x=1773820381; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xcmZE5JSmd9EMTwa5Tp+cNSGVu0husq/Jm3YTdKn7oI=; b=fc7tsK4kOYBl5+AYqTWv4mSnwOfNfwBCu6MckN9lTedKNo7Rdxusw/3ab0nesn1zt9 /H4vK3CWMW78Sl+Gup2oBYRmHdcA30fAewCl73eT1s2ShctGKuiQpdivXxCVE8JxMXb2 0tJ60VCbiJAL1b+PHpol0917g0au0xnykM8SE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773215581; x=1773820381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xcmZE5JSmd9EMTwa5Tp+cNSGVu0husq/Jm3YTdKn7oI=; b=h/Z1Xmwq/FmSWZJXqJzHsGEC6i12m8OQGX/n+wVS/jvR3Pt320sJIq1rGftGnbnO/p FBZVEiWq7613jhtHLokumpQl9gyiE5dTruim6E5aHCJECc5rYlxoV7Fpr+P5R0/zlwUr OZomK4GTuYlqI4sQM2mwzuQdfCarZdfgyHBgpeW/NTdBFnToeE8oh3PtrXJVCggKZO2g 4qizynH0YLfRJX7xnpjvUbzBWIepxa/1DDGTVv1cwJ9Bpu2LJQFj/xX8cSPQm98+OHE9 tdWFbf5BJ73SlTYpLOiLLHvt8TKzLDlTkxb7wfW6QOfNmP3MLZqzhzlkQ3YL6UFOyVPG XIKg== X-Forwarded-Encrypted: i=1; AJvYcCXbQf5B2l2iePZgLfbwKShyDh5Q9mRLbOnxBqiI61PtWyV8M8XixPRx90a2IEDs+Pic+kF3EHW8tLod8gE=@vger.kernel.org X-Gm-Message-State: AOJu0YxpmgeIoFltbRAlnGyXa7ibi0/ySqIEBlmqLwQNGWx6eyMJo3GB r/EmGUVmOiDksLOxgKuVVhIRq/7s7/ZmPIRXjbjJyrTmqgYCoeUnuLV+fcRoauGBYw== X-Gm-Gg: ATEYQzxdGJdtJ7HvtSmC/0W8fg1/eGSYWb2qdiBG584b1Zc53tVkds9K8NaYyXxt3MW e60q1lmxbobkfTdldJz9F2hNAxm63ceDbHHAaAVC/0VEztcpFoUdULC23+cbde4sdWdlA8vkn3U En2OTGWt4ipXsmJcSCNrjw18xcCqIYzIbh3xCF1SHnLHQ2DCihae6fw1YxGq2YeNZZ23Dfb6ybn SAAz3mM+0/DQuY/ueiMgo707fMvwf2akaECHMXyQP1KUMNhpx/I2xE+8S03Q3pymm5ehHKCz2EO lh3/7rLK83VYAMzYxJJGR840BxHA4yZBcYGlnUf+5zF6eXHV40IYYzcpJC0CTU3YQy9LP7z71bm E+rgEJ8uQNL/9k12GzAhhUFveXKGcHLlqa6PEtW3SK0BWCnkfEholEX+RsVsQI+Wi/uKw2WgsmD S2K//SE33QzSiNCkWClrW8Re8A5svTjOars71Dm29DCt5mUjKgzL69skr3NJ1RCFTgKB0x4EXpm V5qwHz8UFhYyrFUUYk= X-Received: by 2002:a17:90b:39cf:b0:359:fcba:6517 with SMTP id 98e67ed59e1d1-35a012df4e8mr1613649a91.19.1773215581116; Wed, 11 Mar 2026 00:53:01 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2a00:79e0:201d:8:805b:14e9:f783:bcae]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35a0236f79asm727816a91.6.2026.03.11.00.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 00:53:00 -0700 (PDT) From: Chen-Yu Tsai To: Matthias Brugger , AngeloGioacchino Del Regno , Ryder Lee , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas Cc: Chen-Yu Tsai , Bartosz Golaszewski , linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 7/7] PCI: mediatek-gen3: Integrate new pwrctrl API Date: Wed, 11 Mar 2026 15:52:22 +0800 Message-ID: <20260311075223.3303497-8-wenst@chromium.org> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog In-Reply-To: <20260311075223.3303497-1-wenst@chromium.org> References: <20260311075223.3303497-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With the new PCI pwrctrl API and PCI slot binding and power drivers, we now have a way to describe and power up WiFi/BT adapters connected through a PCIe or M.2 slot, or populated onto the mainboard itself. The latter case has the adapter layout or design copied verbatim, replacing the slot with direct connections. Integrate the PCI pwrctrl API into the PCIe driver, so that power is properly enabled before PCIe link training is done, allowing the card to successfully be detected. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Bartosz Golaszewski Reviewed-by: Manivannan Sadhasivam Signed-off-by: Chen-Yu Tsai --- Changes since v4: - Replaced "exploded" with "populated" and added explanation that the layout or design is copied verbatim (Bjorn) - Fix build break from label typo; fix was not squashed in correctly in my local tree Changes since v3: - Adapted changes to movement of existing setup code Changes since v2: - Added "select PCI_PWRCTRL_SLOT" to Kconfig to fix kernel test robot compilation error I'm wondering why the two existing uses select PCI_PWRCTRL_SLOT and not PCI_PWRCTRL though. --- drivers/pci/controller/Kconfig | 1 + drivers/pci/controller/pcie-mediatek-gen3.c | 38 ++++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index 5aaed8ac6e44..e72ac6934379 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -222,6 +222,7 @@ config PCIE_MEDIATEK_GEN3 depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST depends on PCI_MSI select IRQ_MSI_LIB + select PCI_PWRCTRL_SLOT help Adds support for PCIe Gen3 MAC controller for MediaTek SoCs. This PCIe controller is compatible with Gen3, Gen2 and Gen1 speed, diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/cont= roller/pcie-mediatek-gen3.c index 208866d33c77..a94fdbaf47fe 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -421,15 +422,23 @@ static int mtk_pcie_devices_power_up(struct mtk_gen3_= pcie *pcie) val |=3D PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB; writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); + } + + err =3D pci_pwrctrl_power_on_devices(pcie->dev); + if (err) { + dev_err(pcie->dev, "Failed to power on devices: %pe\n", ERR_PTR(err)); + return err; + } =20 - /* - * Described in PCIe CEM specification revision 6.0. - * - * The deassertion of PERST# should be delayed 100ms (TPVPERL) - * for the power and clock to become stable. - */ - msleep(PCIE_T_PVPERL_MS); + /* + * Described in PCIe CEM specification revision 6.0. + * + * The deassertion of PERST# should be delayed 100ms (TPVPERL) + * for the power and clock to become stable. + */ + msleep(PCIE_T_PVPERL_MS); =20 + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) { /* De-assert reset signals */ val &=3D ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); @@ -449,6 +458,8 @@ static void mtk_pcie_devices_power_down(struct mtk_gen3= _pcie *pcie) val |=3D PCIE_PE_RSTB; writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); } + + pci_pwrctrl_power_off_devices(pcie->dev); } =20 static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) @@ -1209,9 +1220,15 @@ static int mtk_pcie_probe(struct platform_device *pd= ev) if (err) return dev_err_probe(dev, err, "Failed to setup IRQ domains\n"); =20 + err =3D pci_pwrctrl_create_devices(pcie->dev); + if (err) { + goto err_tear_down_irq; + dev_err_probe(dev, err, "failed to create pwrctrl devices\n"); + } + err =3D mtk_pcie_setup(pcie); if (err) - goto err_tear_down_irq; + goto err_destroy_pwrctrl; =20 host->ops =3D &mtk_pcie_ops; host->sysdata =3D pcie; @@ -1225,6 +1242,9 @@ static int mtk_pcie_probe(struct platform_device *pde= v) err_power_down_pcie: mtk_pcie_devices_power_down(pcie); mtk_pcie_power_down(pcie); +err_destroy_pwrctrl: + if (err !=3D -EPROBE_DEFER) + pci_pwrctrl_destroy_devices(pcie->dev); err_tear_down_irq: mtk_pcie_irq_teardown(pcie); return err; @@ -1240,7 +1260,9 @@ static void mtk_pcie_remove(struct platform_device *p= dev) pci_remove_root_bus(host->bus); pci_unlock_rescan_remove(); =20 + pci_pwrctrl_power_off_devices(pcie->dev); mtk_pcie_power_down(pcie); + pci_pwrctrl_destroy_devices(pcie->dev); mtk_pcie_irq_teardown(pcie); } =20 --=20 2.53.0.473.g4a7958ca14-goog