mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
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>
This commit is contained in:
@@ -52,6 +52,9 @@ int fdt_parse_uart8250_node(void *fdt, int nodeoffset,
|
|||||||
int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
||||||
const char *compatible);
|
const char *compatible);
|
||||||
|
|
||||||
|
int fdt_parse_plic_node(void *fdt, int nodeoffset,
|
||||||
|
struct platform_plic_data *plic);
|
||||||
|
|
||||||
int fdt_parse_plic(void *fdt, struct platform_plic_data *plic,
|
int fdt_parse_plic(void *fdt, struct platform_plic_data *plic,
|
||||||
const char *compatible);
|
const char *compatible);
|
||||||
|
|
||||||
|
@@ -259,16 +259,15 @@ int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
|||||||
return fdt_parse_uart8250_node(fdt, nodeoffset, uart);
|
return fdt_parse_uart8250_node(fdt, nodeoffset, uart);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdt_parse_plic(void *fdt, struct platform_plic_data *plic,
|
int fdt_parse_plic_node(void *fdt, int nodeoffset,
|
||||||
const char *compatible)
|
struct platform_plic_data *plic)
|
||||||
{
|
{
|
||||||
int nodeoffset, len, rc;
|
int len, rc;
|
||||||
const fdt32_t *val;
|
const fdt32_t *val;
|
||||||
unsigned long reg_addr, reg_size;
|
unsigned long reg_addr, reg_size;
|
||||||
|
|
||||||
nodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);
|
if (nodeoffset < 0 || !plic || !fdt)
|
||||||
if (nodeoffset < 0)
|
return SBI_ENODEV;
|
||||||
return nodeoffset;
|
|
||||||
|
|
||||||
rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size);
|
rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size);
|
||||||
if (rc < 0 || !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;
|
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,
|
int fdt_parse_compat_addr(void *fdt, unsigned long *addr,
|
||||||
const char *compatible)
|
const char *compatible)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user