fdtdec: Add API to read pci bus-range property
Add fdtdec_get_pci_bus_range to read bus-range property
values.
Signed-off-by: Suneel Garapati <sgarapati@marvell.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 30a1c6a..d3b22ec 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -243,6 +243,22 @@
return 0;
}
+
+int fdtdec_get_pci_bus_range(const void *blob, int node,
+ struct fdt_resource *res)
+{
+ const u32 *values;
+ int len;
+
+ values = fdt_getprop(blob, node, "bus-range", &len);
+ if (!values || len < sizeof(*values) * 2)
+ return -EINVAL;
+
+ res->start = fdt32_to_cpu(*values++);
+ res->end = fdt32_to_cpu(*values);
+
+ return 0;
+}
#endif
uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,