From patchwork Fri Jun 12 16:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 242198 List-Id: U-Boot discussion From: nsaenzjulienne at suse.de (Nicolas Saenz Julienne) Date: Fri, 12 Jun 2020 18:46:32 +0200 Subject: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge In-Reply-To: <20200612164632.25648-1-nsaenzjulienne@suse.de> References: <20200612164632.25648-1-nsaenzjulienne@suse.de> Message-ID: <20200612164632.25648-5-nsaenzjulienne@suse.de> There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node. This permits setups like this to work correctly: pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; }; Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected. Signed-off-by: Nicolas Saenz Julienne --- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 9ab3539a49..ea27e78465 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -762,7 +762,20 @@ static int pci_find_and_bind_driver(struct udevice *parent, str = strdup(name); if (!str) return -ENOMEM; - drv = bridge ? "pci_bridge_drv" : "pci_generic_drv"; + + if (bridge) { + drv = "pci_bridge_drv"; + + /* + * If we're dealing with the root bridge pass the parent device + * node, as there isn't a distinction in device tree between + * that and the actual controller platform device. + */ + if (!PCI_MASK_BUS(bdf)) + node = parent->node; + } else { + drv = "pci_generic_drv"; + } ret = device_bind_driver_to_node(parent, drv, str, node, devp); if (ret) {