[PATCH 0/6] Add support for the root PCI bus device-tree node creation.

Herve Codina
2024-11-04T17:20:10Z

Hi,

This series adds support for creating a device-tree node for a root PCI
bus on non device-tree based system.

Creating device-tree nodes for PCI devices already exists upstream. It
was added in commit 407d1a51921e ("PCI: Create device tree node for
bridge"). Created device-tree nodes need a parent node to be attached
to. For the first level devices, on device-tree based system, this
parent node (i.e. the root PCI bus) is described in the base device-tree
(PCI controller).

The LAN966x PCI device driver was recently accepted [1] and relies on
this feature.

On system where the base hardware is not described by a device-tree, the
root PCI bus node to which first level created PCI devices need to be
attach to does not exist. This is the case for instance on ACPI
described systems such as x86.

This series goal is to handle this case.

In order to have the root PCI bus device-tree node available even on
x86, this top level node is created (if not already present) based on
information computed by the PCI core. It follows the same mechanism as
the one used for PCI devices device-tree node creation.

In order to have this feature available, a number of changes are needed:
- Patch 1 and 2: Introduce and use device_{add,remove}_of_node().
This function will also be used in the root PCI bus node creation.

- Patch 3 and 4: Improve existing functions to reuse them in the root
PCI bus node creation.

- Patch 5: Update the default value used when #address-cells is not
available in the device-tree root node.

- Patch 6: The root PCI bus device-tree node creation itself.

With those modifications, the LAN966x PCI device is working on x86 systems.

[1] https://lore.kernel.org/lkml/7512cbb7911b8395d926e9e9e390fbb55ce3aea9.camel@pengutronix.de/

Best regards,
Hervé Codina

Herve Codina (6):
driver core: Introduce device_{add,remove}_of_node()
PCI: of: Use device_{add,remove}_of_node() to attach of_node to
existing device
PCI: of_property: Add support for NULL pdev in of_pci_set_address()
PCI: of_property: Constify parameter in of_pci_get_addr_flags()
of: Use the standards compliant default address cells value for x86
PCI: of: Create device-tree root bus node

drivers/base/core.c | 52 ++++++++++++++++++
drivers/of/of_private.h | 2 +-
drivers/pci/of.c | 89 +++++++++++++++++++++++++++++-
drivers/pci/of_property.c | 113 ++++++++++++++++++++++++++++++++++++--
drivers/pci/pci.h | 6 ++
drivers/pci/probe.c | 2 +
drivers/pci/remove.c | 2 +
include/linux/device.h | 2 +
8 files changed, 260 insertions(+), 8 deletions(-)

--
2.46.2