From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Wed, 8 Aug 2018 15:03:02 +0200 Subject: [U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes Message-ID: <20180808130302.23327-1-marek.vasut+renesas@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Cc: Simon Glass --- drivers/pci/pci-uclass.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 46e9c71bdf..306bea0dbf 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice *parent, for (id = entry->match; id->vendor || id->subvendor || id->class_mask; id++) { + ofnode node; + if (!pci_match_one_id(id, find_id)) continue; @@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice *parent, goto error; debug("%s: Match found: %s\n", __func__, drv->name); dev->driver_data = find_id->driver_data; + + dev_for_each_subnode(node, parent) { + phys_addr_t df, size; + df = ofnode_get_addr_size(node, "reg", &size); + + if (PCI_FUNC(df) == PCI_FUNC(bdf) && + PCI_DEV(df) == PCI_DEV(bdf)) { + dev->node = node; + break; + } + } + *devp = dev; return 0; } -- 2.16.2