The PCI controller can have DT subnodes describing extra properties
of particular PCI devices, ie. a PHY attached to an EHCI controller
on a PCI bus. This patch parses those DT subnodes and assigns a node
to the PCI device instance, so that the driver can extract details
from that node and ie. configure the PHY using the PHY subsystem.

Signed-off-by: Marek Vasut <marek.vasut+rene...@gmail.com>
Cc: Simon Glass <s...@chromium.org>
Cc: Tom Rini <tr...@konsulko.com>
---
V2: Move the whole machinery to pci_bind_bus_devices(), right after
    the driver instance platform data are updated. This reduces the
    number of times the DT is traversed and works for both DT nodes
    with and without compat string.
---
 drivers/pci/pci-uclass.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index e9671d9b76..cf3e38a6f2 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -733,6 +733,7 @@ int pci_bind_bus_devices(struct udevice *bus)
        ulong vendor, device;
        ulong header_type;
        pci_dev_t bdf, end;
+       ofnode node;
        bool found_multi;
        int ret;
 
@@ -803,6 +804,20 @@ int pci_bind_bus_devices(struct udevice *bus)
                pplat->vendor = vendor;
                pplat->device = device;
                pplat->class = class;
+
+               /* Associate potention OF node */
+               dev_for_each_subnode(node, bus) {
+                       phys_addr_t df, size;
+                       df = ofnode_get_addr_size(node, "reg", &size);
+                       if (df == FDT_ADDR_T_NONE)
+                               continue;
+
+                       if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
+                           PCI_DEV(df) == PCI_DEV(bdf)) {
+                               dev->node = node;
+                               break;
+                       }
+               }
        }
 
        return 0;
-- 
2.16.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to