forked from Mirrors/opensbi
lib: utils: Add fdt_parse_uart8250_node() function
We add fdt_parse_uart8250_node() function which will allow us to parse a particular DT node as UART 8250 node. This will be useful in parsing the node pointed by stdout-path. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
@@ -23,6 +23,9 @@ struct platform_plic_data {
|
|||||||
unsigned long num_src;
|
unsigned long num_src;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int fdt_parse_uart8250_node(void *fdt, int nodeoffset,
|
||||||
|
struct platform_uart_data *uart);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
@@ -58,21 +58,15 @@ static int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
int fdt_parse_uart8250_node(void *fdt, int nodeoffset,
|
||||||
const char *compatible)
|
struct platform_uart_data *uart)
|
||||||
{
|
{
|
||||||
int nodeoffset, len, rc;
|
int len, rc;
|
||||||
fdt32_t *val;
|
const fdt32_t *val;
|
||||||
unsigned long reg_addr, reg_size;
|
unsigned long reg_addr, reg_size;
|
||||||
|
|
||||||
/**
|
if (nodeoffset < 0 || !uart || !fdt)
|
||||||
* TODO: We don't know how to handle multiple nodes with the same
|
return SBI_ENODEV;
|
||||||
* compatible sring. Just return the first node for now.
|
|
||||||
*/
|
|
||||||
|
|
||||||
nodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);
|
|
||||||
if (nodeoffset < 0)
|
|
||||||
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)
|
||||||
@@ -80,8 +74,8 @@ int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
|||||||
uart->addr = reg_addr;
|
uart->addr = reg_addr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UART address is mandaotry. clock-frequency and current-speed may not
|
* UART address is mandaotry. clock-frequency and current-speed
|
||||||
* be present. Don't return error.
|
* may not be present. Don't return error.
|
||||||
*/
|
*/
|
||||||
val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "clock-frequency", &len);
|
val = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "clock-frequency", &len);
|
||||||
if (len > 0 && val)
|
if (len > 0 && val)
|
||||||
@@ -110,6 +104,21 @@ int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
|
||||||
|
const char *compatible)
|
||||||
|
{
|
||||||
|
int nodeoffset;
|
||||||
|
|
||||||
|
if (!compatible || !uart || !fdt)
|
||||||
|
return SBI_ENODEV;
|
||||||
|
|
||||||
|
nodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);
|
||||||
|
if (nodeoffset < 0)
|
||||||
|
return nodeoffset;
|
||||||
|
|
||||||
|
return fdt_parse_uart8250_node(fdt, nodeoffset, uart);
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user