diff options
author | Stefan Roese <sr@denx.de> | 2020-08-05 14:56:11 +0300 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2020-08-25 06:41:09 +0300 |
commit | 68f81b857563e8f739323385795f1e99b3d2e598 (patch) | |
tree | 6daa3394dfc750b11d08e78677ecae407dae9f8e /drivers/core/read.c | |
parent | 1db7ee464f28d72bd1af87b1136c9c158833da13 (diff) | |
download | u-boot-68f81b857563e8f739323385795f1e99b3d2e598.tar.xz |
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 <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/read.c')
-rw-r--r-- | drivers/core/read.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/core/read.c b/drivers/core/read.c index 8bb456bc3f..86f3f88170 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -10,6 +10,7 @@ #include <mapmem.h> #include <asm/types.h> #include <asm/io.h> +#include <linux/ioport.h> 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; +} |