]> Git Repo - linux.git/commitdiff
PCI/pwrctrl: Rename pwrctl files to pwrctrl
authorBjorn Helgaas <[email protected]>
Fri, 15 Nov 2024 21:44:27 +0000 (15:44 -0600)
committerKrzysztof Wilczyński <[email protected]>
Thu, 21 Nov 2024 16:01:24 +0000 (16:01 +0000)
To slightly reduce confusion between "pwrctl" (the power controller and
power sequencing framework) and "bwctrl" (the bandwidth controller),
rename "pwrctl" to "pwrctrl" so they use the same "ctrl" suffix.

Rename drivers/pci/pwrctl/ to drivers/pci/pwrctrl/, including the related
MAINTAINERS, include file (include/linux/pci-pwrctl.h), Makefile, and
Kconfig changes.

This is the minimal rename of files only.  A subsequent commit will rename
functions and data structures.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Acked-by: Krzysztof Wilczyński <[email protected]>
13 files changed:
MAINTAINERS
drivers/pci/Kconfig
drivers/pci/Makefile
drivers/pci/pwrctl/Kconfig [deleted file]
drivers/pci/pwrctl/Makefile [deleted file]
drivers/pci/pwrctl/core.c [deleted file]
drivers/pci/pwrctl/pci-pwrctl-pwrseq.c [deleted file]
drivers/pci/pwrctrl/Kconfig [new file with mode: 0644]
drivers/pci/pwrctrl/Makefile [new file with mode: 0644]
drivers/pci/pwrctrl/core.c [new file with mode: 0644]
drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c [new file with mode: 0644]
include/linux/pci-pwrctl.h [deleted file]
include/linux/pci-pwrctrl.h [new file with mode: 0644]

index c27f3190737f8b85779bde5489639c8b899f4fd8..1a6096135424c71650897cdaf63a0d4a1a66e503 100644 (file)
@@ -17910,8 +17910,8 @@ M:      Bartosz Golaszewski <[email protected]>
 L:     [email protected]
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git
-F:     drivers/pci/pwrctl/*
-F:     include/linux/pci-pwrctl.h
+F:     drivers/pci/pwrctrl/*
+F:     include/linux/pci-pwrctrl.h
 
 PCI SUBSYSTEM
 M:     Bjorn Helgaas <[email protected]>
index 0d94e4a967d81d50b9a3f3aebda56d37b36fc271..e1c025698a283c5ad795bdf29775107caee4797a 100644 (file)
@@ -305,6 +305,6 @@ source "drivers/pci/hotplug/Kconfig"
 source "drivers/pci/controller/Kconfig"
 source "drivers/pci/endpoint/Kconfig"
 source "drivers/pci/switch/Kconfig"
-source "drivers/pci/pwrctl/Kconfig"
+source "drivers/pci/pwrctrl/Kconfig"
 
 endif
index 374c5c06d92f9ddc4c8dfc2663b1cc8c979f5b41..39a07890abd12817940b6c0a5c06f89a9b2afd08 100644 (file)
@@ -9,7 +9,7 @@ obj-$(CONFIG_PCI)               += access.o bus.o probe.o host-bridge.o \
 
 obj-$(CONFIG_PCI)              += msi/
 obj-$(CONFIG_PCI)              += pcie/
-obj-$(CONFIG_PCI)              += pwrctl/
+obj-$(CONFIG_PCI)              += pwrctrl/
 
 ifdef CONFIG_PCI
 obj-$(CONFIG_PROC_FS)          += proc.o
diff --git a/drivers/pci/pwrctl/Kconfig b/drivers/pci/pwrctl/Kconfig
deleted file mode 100644 (file)
index 54589bb..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-
-config HAVE_PWRCTL
-       bool
-
-config PCI_PWRCTL
-       tristate
-
-config PCI_PWRCTL_PWRSEQ
-       tristate
-       select POWER_SEQUENCING
-       select PCI_PWRCTL
diff --git a/drivers/pci/pwrctl/Makefile b/drivers/pci/pwrctl/Makefile
deleted file mode 100644 (file)
index d308aae..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-
-obj-$(CONFIG_PCI_PWRCTL)               += pci-pwrctl-core.o
-pci-pwrctl-core-y                      := core.o
-
-obj-$(CONFIG_PCI_PWRCTL_PWRSEQ)                += pci-pwrctl-pwrseq.o
diff --git a/drivers/pci/pwrctl/core.c b/drivers/pci/pwrctl/core.c
deleted file mode 100644 (file)
index bb5a237..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2024 Linaro Ltd.
- */
-
-#include <linux/device.h>
-#include <linux/export.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/pci-pwrctl.h>
-#include <linux/property.h>
-#include <linux/slab.h>
-
-static int pci_pwrctl_notify(struct notifier_block *nb, unsigned long action,
-                            void *data)
-{
-       struct pci_pwrctl *pwrctl = container_of(nb, struct pci_pwrctl, nb);
-       struct device *dev = data;
-
-       if (dev_fwnode(dev) != dev_fwnode(pwrctl->dev))
-               return NOTIFY_DONE;
-
-       switch (action) {
-       case BUS_NOTIFY_ADD_DEVICE:
-               /*
-                * We will have two struct device objects bound to two different
-                * drivers on different buses but consuming the same DT node. We
-                * must not bind the pins twice in this case but only once for
-                * the first device to be added.
-                *
-                * If we got here then the PCI device is the second after the
-                * power control platform device. Mark its OF node as reused.
-                */
-               dev->of_node_reused = true;
-               break;
-       }
-
-       return NOTIFY_DONE;
-}
-
-static void rescan_work_func(struct work_struct *work)
-{
-       struct pci_pwrctl *pwrctl = container_of(work, struct pci_pwrctl, work);
-
-       pci_lock_rescan_remove();
-       pci_rescan_bus(to_pci_dev(pwrctl->dev->parent)->bus);
-       pci_unlock_rescan_remove();
-}
-
-/**
- * pci_pwrctl_init() - Initialize the PCI power control context struct
- *
- * @pwrctl: PCI power control data
- * @dev: Parent device
- */
-void pci_pwrctl_init(struct pci_pwrctl *pwrctl, struct device *dev)
-{
-       pwrctl->dev = dev;
-       INIT_WORK(&pwrctl->work, rescan_work_func);
-}
-EXPORT_SYMBOL_GPL(pci_pwrctl_init);
-
-/**
- * pci_pwrctl_device_set_ready() - Notify the pwrctl subsystem that the PCI
- * device is powered-up and ready to be detected.
- *
- * @pwrctl: PCI power control data.
- *
- * Returns:
- * 0 on success, negative error number on error.
- *
- * Note:
- * This function returning 0 doesn't mean the device was detected. It means,
- * that the bus rescan was successfully started. The device will get bound to
- * its PCI driver asynchronously.
- */
-int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl)
-{
-       int ret;
-
-       if (!pwrctl->dev)
-               return -ENODEV;
-
-       pwrctl->nb.notifier_call = pci_pwrctl_notify;
-       ret = bus_register_notifier(&pci_bus_type, &pwrctl->nb);
-       if (ret)
-               return ret;
-
-       schedule_work(&pwrctl->work);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(pci_pwrctl_device_set_ready);
-
-/**
- * pci_pwrctl_device_unset_ready() - Notify the pwrctl subsystem that the PCI
- * device is about to be powered-down.
- *
- * @pwrctl: PCI power control data.
- */
-void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl)
-{
-       /*
-        * We don't have to delete the link here. Typically, this function
-        * is only called when the power control device is being detached. If
-        * it is being detached then the child PCI device must have already
-        * been unbound too or the device core wouldn't let us unbind.
-        */
-       bus_unregister_notifier(&pci_bus_type, &pwrctl->nb);
-}
-EXPORT_SYMBOL_GPL(pci_pwrctl_device_unset_ready);
-
-static void devm_pci_pwrctl_device_unset_ready(void *data)
-{
-       struct pci_pwrctl *pwrctl = data;
-
-       pci_pwrctl_device_unset_ready(pwrctl);
-}
-
-/**
- * devm_pci_pwrctl_device_set_ready - Managed variant of
- * pci_pwrctl_device_set_ready().
- *
- * @dev: Device managing this pwrctl provider.
- * @pwrctl: PCI power control data.
- *
- * Returns:
- * 0 on success, negative error number on error.
- */
-int devm_pci_pwrctl_device_set_ready(struct device *dev,
-                                    struct pci_pwrctl *pwrctl)
-{
-       int ret;
-
-       ret = pci_pwrctl_device_set_ready(pwrctl);
-       if (ret)
-               return ret;
-
-       return devm_add_action_or_reset(dev,
-                                       devm_pci_pwrctl_device_unset_ready,
-                                       pwrctl);
-}
-EXPORT_SYMBOL_GPL(devm_pci_pwrctl_device_set_ready);
-
-MODULE_AUTHOR("Bartosz Golaszewski <[email protected]>");
-MODULE_DESCRIPTION("PCI Device Power Control core driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c b/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c
deleted file mode 100644 (file)
index a23a431..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2024 Linaro Ltd.
- */
-
-#include <linux/device.h>
-#include <linux/mod_devicetable.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/pci-pwrctl.h>
-#include <linux/platform_device.h>
-#include <linux/pwrseq/consumer.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-
-struct pci_pwrctl_pwrseq_data {
-       struct pci_pwrctl ctx;
-       struct pwrseq_desc *pwrseq;
-};
-
-static void devm_pci_pwrctl_pwrseq_power_off(void *data)
-{
-       struct pwrseq_desc *pwrseq = data;
-
-       pwrseq_power_off(pwrseq);
-}
-
-static int pci_pwrctl_pwrseq_probe(struct platform_device *pdev)
-{
-       struct pci_pwrctl_pwrseq_data *data;
-       struct device *dev = &pdev->dev;
-       int ret;
-
-       data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
-       if (!data)
-               return -ENOMEM;
-
-       data->pwrseq = devm_pwrseq_get(dev, of_device_get_match_data(dev));
-       if (IS_ERR(data->pwrseq))
-               return dev_err_probe(dev, PTR_ERR(data->pwrseq),
-                                    "Failed to get the power sequencer\n");
-
-       ret = pwrseq_power_on(data->pwrseq);
-       if (ret)
-               return dev_err_probe(dev, ret,
-                                    "Failed to power-on the device\n");
-
-       ret = devm_add_action_or_reset(dev, devm_pci_pwrctl_pwrseq_power_off,
-                                      data->pwrseq);
-       if (ret)
-               return ret;
-
-       pci_pwrctl_init(&data->ctx, dev);
-
-       ret = devm_pci_pwrctl_device_set_ready(dev, &data->ctx);
-       if (ret)
-               return dev_err_probe(dev, ret,
-                                    "Failed to register the pwrctl wrapper\n");
-
-       return 0;
-}
-
-static const struct of_device_id pci_pwrctl_pwrseq_of_match[] = {
-       {
-               /* ATH11K in QCA6390 package. */
-               .compatible = "pci17cb,1101",
-               .data = "wlan",
-       },
-       {
-               /* ATH11K in WCN6855 package. */
-               .compatible = "pci17cb,1103",
-               .data = "wlan",
-       },
-       {
-               /* ATH12K in WCN7850 package. */
-               .compatible = "pci17cb,1107",
-               .data = "wlan",
-       },
-       { }
-};
-MODULE_DEVICE_TABLE(of, pci_pwrctl_pwrseq_of_match);
-
-static struct platform_driver pci_pwrctl_pwrseq_driver = {
-       .driver = {
-               .name = "pci-pwrctl-pwrseq",
-               .of_match_table = pci_pwrctl_pwrseq_of_match,
-       },
-       .probe = pci_pwrctl_pwrseq_probe,
-};
-module_platform_driver(pci_pwrctl_pwrseq_driver);
-
-MODULE_AUTHOR("Bartosz Golaszewski <[email protected]>");
-MODULE_DESCRIPTION("Generic PCI Power Control module for power sequenced devices");
-MODULE_LICENSE("GPL");
diff --git a/drivers/pci/pwrctrl/Kconfig b/drivers/pci/pwrctrl/Kconfig
new file mode 100644 (file)
index 0000000..54589bb
--- /dev/null
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config HAVE_PWRCTL
+       bool
+
+config PCI_PWRCTL
+       tristate
+
+config PCI_PWRCTL_PWRSEQ
+       tristate
+       select POWER_SEQUENCING
+       select PCI_PWRCTL
diff --git a/drivers/pci/pwrctrl/Makefile b/drivers/pci/pwrctrl/Makefile
new file mode 100644 (file)
index 0000000..75c7ce5
--- /dev/null
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_PCI_PWRCTL)               += pci-pwrctrl-core.o
+pci-pwrctrl-core-y                     := core.o
+
+obj-$(CONFIG_PCI_PWRCTL_PWRSEQ)                += pci-pwrctrl-pwrseq.o
diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c
new file mode 100644 (file)
index 0000000..88f06e9
--- /dev/null
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2024 Linaro Ltd.
+ */
+
+#include <linux/device.h>
+#include <linux/export.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/pci-pwrctrl.h>
+#include <linux/property.h>
+#include <linux/slab.h>
+
+static int pci_pwrctl_notify(struct notifier_block *nb, unsigned long action,
+                            void *data)
+{
+       struct pci_pwrctl *pwrctl = container_of(nb, struct pci_pwrctl, nb);
+       struct device *dev = data;
+
+       if (dev_fwnode(dev) != dev_fwnode(pwrctl->dev))
+               return NOTIFY_DONE;
+
+       switch (action) {
+       case BUS_NOTIFY_ADD_DEVICE:
+               /*
+                * We will have two struct device objects bound to two different
+                * drivers on different buses but consuming the same DT node. We
+                * must not bind the pins twice in this case but only once for
+                * the first device to be added.
+                *
+                * If we got here then the PCI device is the second after the
+                * power control platform device. Mark its OF node as reused.
+                */
+               dev->of_node_reused = true;
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static void rescan_work_func(struct work_struct *work)
+{
+       struct pci_pwrctl *pwrctl = container_of(work, struct pci_pwrctl, work);
+
+       pci_lock_rescan_remove();
+       pci_rescan_bus(to_pci_dev(pwrctl->dev->parent)->bus);
+       pci_unlock_rescan_remove();
+}
+
+/**
+ * pci_pwrctl_init() - Initialize the PCI power control context struct
+ *
+ * @pwrctl: PCI power control data
+ * @dev: Parent device
+ */
+void pci_pwrctl_init(struct pci_pwrctl *pwrctl, struct device *dev)
+{
+       pwrctl->dev = dev;
+       INIT_WORK(&pwrctl->work, rescan_work_func);
+}
+EXPORT_SYMBOL_GPL(pci_pwrctl_init);
+
+/**
+ * pci_pwrctl_device_set_ready() - Notify the pwrctl subsystem that the PCI
+ * device is powered-up and ready to be detected.
+ *
+ * @pwrctl: PCI power control data.
+ *
+ * Returns:
+ * 0 on success, negative error number on error.
+ *
+ * Note:
+ * This function returning 0 doesn't mean the device was detected. It means,
+ * that the bus rescan was successfully started. The device will get bound to
+ * its PCI driver asynchronously.
+ */
+int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl)
+{
+       int ret;
+
+       if (!pwrctl->dev)
+               return -ENODEV;
+
+       pwrctl->nb.notifier_call = pci_pwrctl_notify;
+       ret = bus_register_notifier(&pci_bus_type, &pwrctl->nb);
+       if (ret)
+               return ret;
+
+       schedule_work(&pwrctl->work);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(pci_pwrctl_device_set_ready);
+
+/**
+ * pci_pwrctl_device_unset_ready() - Notify the pwrctl subsystem that the PCI
+ * device is about to be powered-down.
+ *
+ * @pwrctl: PCI power control data.
+ */
+void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl)
+{
+       /*
+        * We don't have to delete the link here. Typically, this function
+        * is only called when the power control device is being detached. If
+        * it is being detached then the child PCI device must have already
+        * been unbound too or the device core wouldn't let us unbind.
+        */
+       bus_unregister_notifier(&pci_bus_type, &pwrctl->nb);
+}
+EXPORT_SYMBOL_GPL(pci_pwrctl_device_unset_ready);
+
+static void devm_pci_pwrctl_device_unset_ready(void *data)
+{
+       struct pci_pwrctl *pwrctl = data;
+
+       pci_pwrctl_device_unset_ready(pwrctl);
+}
+
+/**
+ * devm_pci_pwrctl_device_set_ready - Managed variant of
+ * pci_pwrctl_device_set_ready().
+ *
+ * @dev: Device managing this pwrctl provider.
+ * @pwrctl: PCI power control data.
+ *
+ * Returns:
+ * 0 on success, negative error number on error.
+ */
+int devm_pci_pwrctl_device_set_ready(struct device *dev,
+                                    struct pci_pwrctl *pwrctl)
+{
+       int ret;
+
+       ret = pci_pwrctl_device_set_ready(pwrctl);
+       if (ret)
+               return ret;
+
+       return devm_add_action_or_reset(dev,
+                                       devm_pci_pwrctl_device_unset_ready,
+                                       pwrctl);
+}
+EXPORT_SYMBOL_GPL(devm_pci_pwrctl_device_set_ready);
+
+MODULE_AUTHOR("Bartosz Golaszewski <[email protected]>");
+MODULE_DESCRIPTION("PCI Device Power Control core driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c b/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
new file mode 100644 (file)
index 0000000..cc19ad6
--- /dev/null
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2024 Linaro Ltd.
+ */
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/pci-pwrctrl.h>
+#include <linux/platform_device.h>
+#include <linux/pwrseq/consumer.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+struct pci_pwrctl_pwrseq_data {
+       struct pci_pwrctl ctx;
+       struct pwrseq_desc *pwrseq;
+};
+
+static void devm_pci_pwrctl_pwrseq_power_off(void *data)
+{
+       struct pwrseq_desc *pwrseq = data;
+
+       pwrseq_power_off(pwrseq);
+}
+
+static int pci_pwrctl_pwrseq_probe(struct platform_device *pdev)
+{
+       struct pci_pwrctl_pwrseq_data *data;
+       struct device *dev = &pdev->dev;
+       int ret;
+
+       data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       data->pwrseq = devm_pwrseq_get(dev, of_device_get_match_data(dev));
+       if (IS_ERR(data->pwrseq))
+               return dev_err_probe(dev, PTR_ERR(data->pwrseq),
+                                    "Failed to get the power sequencer\n");
+
+       ret = pwrseq_power_on(data->pwrseq);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to power-on the device\n");
+
+       ret = devm_add_action_or_reset(dev, devm_pci_pwrctl_pwrseq_power_off,
+                                      data->pwrseq);
+       if (ret)
+               return ret;
+
+       pci_pwrctl_init(&data->ctx, dev);
+
+       ret = devm_pci_pwrctl_device_set_ready(dev, &data->ctx);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register the pwrctl wrapper\n");
+
+       return 0;
+}
+
+static const struct of_device_id pci_pwrctl_pwrseq_of_match[] = {
+       {
+               /* ATH11K in QCA6390 package. */
+               .compatible = "pci17cb,1101",
+               .data = "wlan",
+       },
+       {
+               /* ATH11K in WCN6855 package. */
+               .compatible = "pci17cb,1103",
+               .data = "wlan",
+       },
+       {
+               /* ATH12K in WCN7850 package. */
+               .compatible = "pci17cb,1107",
+               .data = "wlan",
+       },
+       { }
+};
+MODULE_DEVICE_TABLE(of, pci_pwrctl_pwrseq_of_match);
+
+static struct platform_driver pci_pwrctl_pwrseq_driver = {
+       .driver = {
+               .name = "pci-pwrctl-pwrseq",
+               .of_match_table = pci_pwrctl_pwrseq_of_match,
+       },
+       .probe = pci_pwrctl_pwrseq_probe,
+};
+module_platform_driver(pci_pwrctl_pwrseq_driver);
+
+MODULE_AUTHOR("Bartosz Golaszewski <[email protected]>");
+MODULE_DESCRIPTION("Generic PCI Power Control module for power sequenced devices");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/pci-pwrctl.h b/include/linux/pci-pwrctl.h
deleted file mode 100644 (file)
index 0d23ddd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2024 Linaro Ltd.
- */
-
-#ifndef __PCI_PWRCTL_H__
-#define __PCI_PWRCTL_H__
-
-#include <linux/notifier.h>
-#include <linux/workqueue.h>
-
-struct device;
-struct device_link;
-
-/*
- * This is a simple framework for solving the issue of PCI devices that require
- * certain resources (regulators, GPIOs, clocks) to be enabled before the
- * device can actually be detected on the PCI bus.
- *
- * The idea is to reuse the platform bus to populate OF nodes describing the
- * PCI device and its resources, let these platform devices probe and enable
- * relevant resources and then trigger a rescan of the PCI bus allowing for the
- * same device (with a second associated struct device) to be registered with
- * the PCI subsystem.
- *
- * To preserve a correct hierarchy for PCI power management and device reset,
- * we create a device link between the power control platform device (parent)
- * and the supplied PCI device (child).
- */
-
-/**
- * struct pci_pwrctl - PCI device power control context.
- * @dev: Address of the power controlling device.
- *
- * An object of this type must be allocated by the PCI power control device and
- * passed to the pwrctl subsystem to trigger a bus rescan and setup a device
- * link with the device once it's up.
- */
-struct pci_pwrctl {
-       struct device *dev;
-
-       /* Private: don't use. */
-       struct notifier_block nb;
-       struct device_link *link;
-       struct work_struct work;
-};
-
-void pci_pwrctl_init(struct pci_pwrctl *pwrctl, struct device *dev);
-int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl);
-void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl);
-int devm_pci_pwrctl_device_set_ready(struct device *dev,
-                                    struct pci_pwrctl *pwrctl);
-
-#endif /* __PCI_PWRCTL_H__ */
diff --git a/include/linux/pci-pwrctrl.h b/include/linux/pci-pwrctrl.h
new file mode 100644 (file)
index 0000000..0d23ddd
--- /dev/null
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2024 Linaro Ltd.
+ */
+
+#ifndef __PCI_PWRCTL_H__
+#define __PCI_PWRCTL_H__
+
+#include <linux/notifier.h>
+#include <linux/workqueue.h>
+
+struct device;
+struct device_link;
+
+/*
+ * This is a simple framework for solving the issue of PCI devices that require
+ * certain resources (regulators, GPIOs, clocks) to be enabled before the
+ * device can actually be detected on the PCI bus.
+ *
+ * The idea is to reuse the platform bus to populate OF nodes describing the
+ * PCI device and its resources, let these platform devices probe and enable
+ * relevant resources and then trigger a rescan of the PCI bus allowing for the
+ * same device (with a second associated struct device) to be registered with
+ * the PCI subsystem.
+ *
+ * To preserve a correct hierarchy for PCI power management and device reset,
+ * we create a device link between the power control platform device (parent)
+ * and the supplied PCI device (child).
+ */
+
+/**
+ * struct pci_pwrctl - PCI device power control context.
+ * @dev: Address of the power controlling device.
+ *
+ * An object of this type must be allocated by the PCI power control device and
+ * passed to the pwrctl subsystem to trigger a bus rescan and setup a device
+ * link with the device once it's up.
+ */
+struct pci_pwrctl {
+       struct device *dev;
+
+       /* Private: don't use. */
+       struct notifier_block nb;
+       struct device_link *link;
+       struct work_struct work;
+};
+
+void pci_pwrctl_init(struct pci_pwrctl *pwrctl, struct device *dev);
+int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl);
+void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl);
+int devm_pci_pwrctl_device_set_ready(struct device *dev,
+                                    struct pci_pwrctl *pwrctl);
+
+#endif /* __PCI_PWRCTL_H__ */
This page took 0.112556 seconds and 4 git commands to generate.