[U-Boot] [PATCH V3 1/2] pci: Support parsing PCI controller DT subnodes
Simon Glass
sjg at chromium.org
Fri Sep 14 04:41:33 UTC 2018
Hi Marek,
On 11 September 2018 at 14:58, Marek Vasut <marek.vasut at gmail.com> wrote:
> 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+renesas at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at konsulko.com>
> ---
> V3: Reword the comment
> 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..ab8818280d 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 optional 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;
> + }
> + }
> }
You should only need to do this if dev->node is not already valid.
How about:
if (!ofnode_valid(dev->node))
find_ofnode_for_dev(dev);
then put your code in that fnuction...
Regards,
Simon
More information about the U-Boot
mailing list