summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-04-29 11:51:52 +0300
committerAnup Patel <anup@brainfault.org>2020-05-01 07:15:53 +0300
commitf0eb503db4c14176f165ca067798b079571decda (patch)
tree4ed68de756595a488221790abc6a4cc4f150d2b4 /lib
parent44dd7be3b2b3b821912e32a1021706a2edb9d44b (diff)
downloadopensbi-f0eb503db4c14176f165ca067798b079571decda.tar.xz
lib: utils: Add fdt_parse_plic_node() function
We add fdt_parse_plic_node() function which will allow us to parse a particular DT node as PLIC node. This will be useful in parsing the DT node which we have found by matching compatible string. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/fdt/fdt_helper.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 2d79f75..ee733e7 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -259,16 +259,15 @@ int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
return fdt_parse_uart8250_node(fdt, nodeoffset, uart);
}
-int fdt_parse_plic(void *fdt, struct platform_plic_data *plic,
- const char *compatible)
+int fdt_parse_plic_node(void *fdt, int nodeoffset,
+ struct platform_plic_data *plic)
{
- int nodeoffset, len, rc;
+ int len, rc;
const fdt32_t *val;
unsigned long reg_addr, reg_size;
- nodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);
- if (nodeoffset < 0)
- return nodeoffset;
+ if (nodeoffset < 0 || !plic || !fdt)
+ return SBI_ENODEV;
rc = fdt_get_node_addr_size(fdt, nodeoffset, &reg_addr, &reg_size);
if (rc < 0 || !reg_addr || !reg_size)
@@ -282,6 +281,21 @@ int fdt_parse_plic(void *fdt, struct platform_plic_data *plic,
return 0;
}
+int fdt_parse_plic(void *fdt, struct platform_plic_data *plic,
+ const char *compatible)
+{
+ int nodeoffset;
+
+ if (!compatible || !plic || !fdt)
+ return SBI_ENODEV;
+
+ nodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);
+ if (nodeoffset < 0)
+ return nodeoffset;
+
+ return fdt_parse_plic_node(fdt, nodeoffset, plic);
+}
+
int fdt_parse_compat_addr(void *fdt, unsigned long *addr,
const char *compatible)
{