Skip to content

Commit 8fb1861

Browse files
author
Bartosz Golaszewski
committed
PCI/pwrctl: Create platform devices for child OF nodes of the port node
In preparation for introducing PCI device power control - a set of library functions that will allow powering-up of PCI devices before they're detected on the PCI bus - we need to populate the devices defined on the device-tree. We are reusing the platform bus as it provides us with all the infrastructure we need to match the pwrctl drivers against the compatibles from OF nodes. These platform devices will be probed by the driver core and bound to the PCI pwrctl drivers we'll introduce later. Tested-by: Amit Pundir <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on SM8550-QRD, SM8650-QRD & SM8650-HDK Tested-by: Caleb Connolly <[email protected]> # OnePlus 8T Acked-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 62c953f commit 8fb1861

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

drivers/pci/bus.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/errno.h>
1313
#include <linux/ioport.h>
1414
#include <linux/of.h>
15+
#include <linux/of_platform.h>
1516
#include <linux/proc_fs.h>
1617
#include <linux/slab.h>
1718

@@ -354,6 +355,14 @@ void pci_bus_add_device(struct pci_dev *dev)
354355
pci_warn(dev, "device attach failed (%d)\n", retval);
355356

356357
pci_dev_assign_added(dev, true);
358+
359+
if (pci_is_bridge(dev)) {
360+
retval = of_platform_populate(dev->dev.of_node, NULL, NULL,
361+
&dev->dev);
362+
if (retval)
363+
pci_err(dev, "failed to populate child OF nodes (%d)\n",
364+
retval);
365+
}
357366
}
358367
EXPORT_SYMBOL_GPL(pci_bus_add_device);
359368

drivers/pci/remove.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/pci.h>
33
#include <linux/module.h>
4+
#include <linux/of_platform.h>
45
#include "pci.h"
56

67
static void pci_free_resources(struct pci_dev *dev)
@@ -18,7 +19,7 @@ static void pci_stop_dev(struct pci_dev *dev)
1819
pci_pme_active(dev, false);
1920

2021
if (pci_dev_is_added(dev)) {
21-
22+
of_platform_depopulate(&dev->dev);
2223
device_release_driver(&dev->dev);
2324
pci_proc_detach_device(dev);
2425
pci_remove_sysfs_dev_files(dev);

0 commit comments

Comments
 (0)