diff options
author | Thierry Reding <treding@nvidia.com> | 2014-08-26 17:33:54 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2014-10-22 16:56:41 -0600 |
commit | 9f85eee72a2a3918b2d5cd7b1bf88da69232dede (patch) | |
tree | 18ad49344920b3e9721550b4172f623f126412f9 /lib/fdtdec.c | |
parent | 56f42242f020254ea1c383694edb072e3a5ca6d6 (diff) | |
download | u-boot-imx-9f85eee72a2a3918b2d5cd7b1bf88da69232dede.zip u-boot-imx-9f85eee72a2a3918b2d5cd7b1bf88da69232dede.tar.gz u-boot-imx-9f85eee72a2a3918b2d5cd7b1bf88da69232dede.tar.bz2 |
fdt: Add a function to return PCI BDF triplet
The fdtdec_pci_get_bdf() function returns the bus, device, function
triplet of a PCI device by parsing the "reg" property according to the
PCI device tree binding.
Acked-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r-- | lib/fdtdec.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index b3c43be..4f66ae1 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -765,4 +765,18 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property, return fdt_get_resource(fdt, node, property, index, res); } + +int fdtdec_pci_get_bdf(const void *fdt, int node, int *bdf) +{ + const fdt32_t *prop; + int len; + + prop = fdt_getprop(fdt, node, "reg", &len); + if (!prop) + return len; + + *bdf = fdt32_to_cpu(*prop) & 0xffffff; + + return 0; +} #endif |