From 68f81b857563e8f739323385795f1e99b3d2e598 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 5 Aug 2020 13:56:11 +0200 Subject: dm: core: Add API to read PCI bus-range property Add dev_read_pci_bus_range() to read bus-range property values Signed-off-by: Stefan Roese Reviewed-by: Simon Glass --- drivers/core/read.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/core') diff --git a/drivers/core/read.c b/drivers/core/read.c index 8bb456bc3f0..86f3f881706 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -10,6 +10,7 @@ #include #include #include +#include int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp) { @@ -359,3 +360,19 @@ int dev_get_child_count(const struct udevice *dev) { return ofnode_get_child_count(dev_ofnode(dev)); } + +int dev_read_pci_bus_range(const struct udevice *dev, + struct resource *res) +{ + const u32 *values; + int len; + + values = dev_read_prop(dev, "bus-range", &len); + if (!values || len < sizeof(*values) * 2) + return -EINVAL; + + res->start = *values++; + res->end = *values; + + return 0; +} -- cgit v1.2.3