[PATCH 5/7] PCI: mediatek-gen3: Integrate new pwrctrl API
Manivannan Sadhasivam
mani at kernel.org
Wed Feb 25 05:20:19 PST 2026
On Wed, Feb 25, 2026 at 03:22:22PM +0800, Chen-Yu Tsai wrote:
> 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 exploded onto the mainboard itself.
>
> 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.
>
> Signed-off-by: Chen-Yu Tsai <wenst at chromium.org>
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 38 ++++++++++++++++-----
> 1 file changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 7459e1c1899d..93e591f788f7 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -22,6 +22,7 @@
> #include <linux/of_device.h>
> #include <linux/of_pci.h>
> #include <linux/pci.h>
> +#include <linux/pci-pwrctrl.h>
> #include <linux/phy/phy.h>
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> @@ -421,15 +422,23 @@ static int mtk_pcie_device_power_up(struct mtk_gen3_pcie *pcie)
> val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> PCIE_PE_RSTB;
> writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> + }
> +
> + err = 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;
> + }
>
> - /*
> - * 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);
>
> + if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
> /* De-assert reset signals */
> val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
> PCIE_PE_RSTB);
> @@ -449,6 +458,8 @@ static void mtk_pcie_device_power_down(struct mtk_gen3_pcie *pcie)
> val |= PCIE_PE_RSTB;
> writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
> }
> +
> + pci_pwrctrl_power_off_devices(pcie->dev);
> }
>
> static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
> @@ -1211,9 +1222,13 @@ static int mtk_pcie_probe(struct platform_device *pdev)
> pcie->soc = device_get_match_data(dev);
> platform_set_drvdata(pdev, pcie);
>
> + err = pci_pwrctrl_create_devices(pcie->dev);
> + if (err)
> + return dev_err_probe(dev, err, "failed to create pwrctrl devices\n");
> +
> err = mtk_pcie_setup(pcie);
> if (err)
> - return err;
> + goto err_destroy_pwrctrl;
>
> host->ops = &mtk_pcie_ops;
> host->sysdata = pcie;
> @@ -1226,7 +1241,12 @@ static int mtk_pcie_probe(struct platform_device *pdev)
>
> err_teardown_irq_and_power_down:
> mtk_pcie_irq_teardown(pcie);
> + mtk_pcie_device_power_down(pcie);
> mtk_pcie_power_down(pcie);
> +err_destroy_pwrctrl:
> + if (err != -EPROBE_DEFER)
Sorry for this mess. I hope to fix it soon.
- Mani
--
மணிவண்ணன் சதாசிவம்
More information about the linux-arm-kernel
mailing list