Re: [PATCH v4 3/9] pci: pwrctrl: rename pci-pwrctrl-slot as generic

From: Manivannan Sadhasivam

Date: Mon Feb 16 2026 - 11:38:31 EST


On Mon, Feb 16, 2026 at 03:21:47PM +0100, Neil Armstrong wrote:
> The driver is pretty generic and would fit for either
> PCI Slots or endpoints connected to PCI ports, so rename
> the driver and module as pci-pwrctrl-generic.
>
> Suggested-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> Signed-off-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx>
> ---
> drivers/pci/pwrctrl/Kconfig | 13 ++++---
> drivers/pci/pwrctrl/Makefile | 4 +-
> drivers/pci/pwrctrl/generic.c | 91 +++++++++++++++++++++++++++++++++++++++++++
> drivers/pci/pwrctrl/slot.c | 91 -------------------------------------------
> 4 files changed, 100 insertions(+), 99 deletions(-)
>
> diff --git a/drivers/pci/pwrctrl/Kconfig b/drivers/pci/pwrctrl/Kconfig
> index e0f999f299bb..0ba095729694 100644
> --- a/drivers/pci/pwrctrl/Kconfig
> +++ b/drivers/pci/pwrctrl/Kconfig
> @@ -11,16 +11,17 @@ config PCI_PWRCTRL_PWRSEQ
> select POWER_SEQUENCING
> select PCI_PWRCTRL
>
> -config PCI_PWRCTRL_SLOT
> - tristate "PCI Power Control driver for PCI slots"

This symbol is selected by a few controller drivers also in:
drivers/pci/controller/dwc/Kconfig

> +config PCI_PWRCTRL_GENERIC
> + tristate "Generic PCI Power Control driver for PCI slots and endpoints"
> select PCI_PWRCTRL
> help
> - Say Y here to enable the PCI Power Control driver to control the power
> - state of PCI slots.
> + Say Y here to enable the generic PCI Power Control driver to control
> + the power state of PCI slots and endpoints.
>
> This is a generic driver that controls the power state of different
> - PCI slots. The voltage regulators powering the rails of the PCI slots
> - are expected to be defined in the devicetree node of the PCI bridge.
> + PCI slots and endpoints. The voltage regulators powering the rails
> + of the PCI slots or endpoints are expected to be defined in the
> + devicetree node of the PCI bridge.
>
> config PCI_PWRCTRL_TC9563
> tristate "PCI Power Control driver for TC9563 PCIe switch"
> diff --git a/drivers/pci/pwrctrl/Makefile b/drivers/pci/pwrctrl/Makefile
> index 13b02282106c..f6bb4fb9a410 100644
> --- a/drivers/pci/pwrctrl/Makefile
> +++ b/drivers/pci/pwrctrl/Makefile
> @@ -5,7 +5,7 @@ pci-pwrctrl-core-y := core.o
>
> obj-$(CONFIG_PCI_PWRCTRL_PWRSEQ) += pci-pwrctrl-pwrseq.o
>
> -obj-$(CONFIG_PCI_PWRCTRL_SLOT) += pci-pwrctrl-slot.o
> -pci-pwrctrl-slot-y := slot.o
> +obj-$(CONFIG_PCI_PWRCTRL_GENERIC) += pci-pwrctrl-generic.o
> +pci-pwrctrl-generic-y := generic.o
>
> obj-$(CONFIG_PCI_PWRCTRL_TC9563) += pci-pwrctrl-tc9563.o
> diff --git a/drivers/pci/pwrctrl/generic.c b/drivers/pci/pwrctrl/generic.c
> new file mode 100644
> index 000000000000..a5b7b7965f46
> --- /dev/null
> +++ b/drivers/pci/pwrctrl/generic.c
> @@ -0,0 +1,91 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2024 Linaro Ltd.
> + * Author: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/pci-pwrctrl.h>
> +#include <linux/platform_device.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/slab.h>
> +
> +struct pci_pwrctrl_generic_data {

Ah, just realised that Bjorn renamed these structures and helpers in
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/drivers/pci/pwrctrl/slot.c?h=next&id=e40d16e6c23994b28894179b87f9747edd63062a

So this needs some adapting...

- Mani

> + struct pci_pwrctrl ctx;
> + struct regulator_bulk_data *supplies;
> + int num_supplies;
> +};
> +
> +static void devm_pci_pwrctrl_generic_power_off(void *data)
> +{
> + struct pci_pwrctrl_generic_data *generic = data;
> +
> + regulator_bulk_disable(generic->num_supplies, generic->supplies);
> + regulator_bulk_free(generic->num_supplies, generic->supplies);
> +}
> +
> +static int pci_pwrctrl_generic_probe(struct platform_device *pdev)
> +{
> + struct pci_pwrctrl_generic_data *generic;
> + struct device *dev = &pdev->dev;
> + struct clk *clk;
> + int ret;
> +
> + generic = devm_kzalloc(dev, sizeof(*generic), GFP_KERNEL);
> + if (!generic)
> + return -ENOMEM;
> +
> + ret = of_regulator_bulk_get_all(dev, dev_of_node(dev),
> + &generic->supplies);
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "Failed to get regulators\n");
> +
> + generic->num_supplies = ret;
> + ret = regulator_bulk_enable(generic->num_supplies, generic->supplies);
> + if (ret < 0) {
> + regulator_bulk_free(generic->num_supplies, generic->supplies);
> + return dev_err_probe(dev, ret, "Failed to enable regulators\n");
> + }
> +
> + ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_generic_power_off,
> + generic);
> + if (ret)
> + return ret;
> +
> + clk = devm_clk_get_optional_enabled(dev, NULL);
> + if (IS_ERR(clk))
> + return dev_err_probe(dev, PTR_ERR(clk),
> + "Failed to enable clock\n");
> +
> + pci_pwrctrl_init(&generic->ctx, dev);
> +
> + ret = devm_pci_pwrctrl_device_set_ready(dev, &generic->ctx);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to register generic pwrctrl driver\n");
> +
> + return 0;
> +}
> +
> +static const struct of_device_id pci_pwrctrl_generic_of_match[] = {
> + {
> + .compatible = "pciclass,0604",
> + },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, pci_pwrctrl_generic_of_match);
> +
> +static struct platform_driver pci_pwrctrl_generic_driver = {
> + .driver = {
> + .name = "pci-pwrctrl-generic",
> + .of_match_table = pci_pwrctrl_generic_of_match,
> + },
> + .probe = pci_pwrctrl_generic_probe,
> +};
> +module_platform_driver(pci_pwrctrl_generic_driver);
> +
> +MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>");
> +MODULE_DESCRIPTION("Generic PCI Power Control driver for PCI Slots");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/pci/pwrctrl/slot.c b/drivers/pci/pwrctrl/slot.c
> deleted file mode 100644
> index 08e53243cdbd..000000000000
> --- a/drivers/pci/pwrctrl/slot.c
> +++ /dev/null
> @@ -1,91 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Copyright (C) 2024 Linaro Ltd.
> - * Author: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
> - */
> -
> -#include <linux/clk.h>
> -#include <linux/device.h>
> -#include <linux/mod_devicetable.h>
> -#include <linux/module.h>
> -#include <linux/pci-pwrctrl.h>
> -#include <linux/platform_device.h>
> -#include <linux/regulator/consumer.h>
> -#include <linux/slab.h>
> -
> -struct pci_pwrctrl_slot_data {
> - struct pci_pwrctrl ctx;
> - struct regulator_bulk_data *supplies;
> - int num_supplies;
> -};
> -
> -static void devm_pci_pwrctrl_slot_power_off(void *data)
> -{
> - struct pci_pwrctrl_slot_data *slot = data;
> -
> - regulator_bulk_disable(slot->num_supplies, slot->supplies);
> - regulator_bulk_free(slot->num_supplies, slot->supplies);
> -}
> -
> -static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
> -{
> - struct pci_pwrctrl_slot_data *slot;
> - struct device *dev = &pdev->dev;
> - struct clk *clk;
> - int ret;
> -
> - slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL);
> - if (!slot)
> - return -ENOMEM;
> -
> - ret = of_regulator_bulk_get_all(dev, dev_of_node(dev),
> - &slot->supplies);
> - if (ret < 0)
> - return dev_err_probe(dev, ret, "Failed to get slot regulators\n");
> -
> - slot->num_supplies = ret;
> - ret = regulator_bulk_enable(slot->num_supplies, slot->supplies);
> - if (ret < 0) {
> - regulator_bulk_free(slot->num_supplies, slot->supplies);
> - return dev_err_probe(dev, ret, "Failed to enable slot regulators\n");
> - }
> -
> - ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off,
> - slot);
> - if (ret)
> - return ret;
> -
> - clk = devm_clk_get_optional_enabled(dev, NULL);
> - if (IS_ERR(clk))
> - return dev_err_probe(dev, PTR_ERR(clk),
> - "Failed to enable slot clock\n");
> -
> - pci_pwrctrl_init(&slot->ctx, dev);
> -
> - ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->ctx);
> - if (ret)
> - return dev_err_probe(dev, ret, "Failed to register pwrctrl driver\n");
> -
> - return 0;
> -}
> -
> -static const struct of_device_id pci_pwrctrl_slot_of_match[] = {
> - {
> - .compatible = "pciclass,0604",
> - },
> - { }
> -};
> -MODULE_DEVICE_TABLE(of, pci_pwrctrl_slot_of_match);
> -
> -static struct platform_driver pci_pwrctrl_slot_driver = {
> - .driver = {
> - .name = "pci-pwrctrl-slot",
> - .of_match_table = pci_pwrctrl_slot_of_match,
> - },
> - .probe = pci_pwrctrl_slot_probe,
> -};
> -module_platform_driver(pci_pwrctrl_slot_driver);
> -
> -MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>");
> -MODULE_DESCRIPTION("Generic PCI Power Control driver for PCI Slots");
> -MODULE_LICENSE("GPL");
>
> --
> 2.34.1
>

--
மணிவண்ணன் சதாசிவம்