mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 22:14:54 +00:00
dm: core: implement ofnode/tree_parse_phandle() helper
Implement ofnode/tree_parse_phandle() helper as an equivalent of of_parse_phandle to handle simple single value phandle. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
8f9cc56a5b
commit
2d31a2797a
2 changed files with 84 additions and 0 deletions
|
@ -879,6 +879,64 @@ int ofnode_read_string_list(ofnode node, const char *property,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ofnode ofnode_parse_phandle(ofnode node, const char *phandle_name,
|
||||||
|
int index)
|
||||||
|
{
|
||||||
|
ofnode phandle;
|
||||||
|
|
||||||
|
if (ofnode_is_np(node)) {
|
||||||
|
struct device_node *np;
|
||||||
|
|
||||||
|
np = of_parse_phandle(ofnode_to_np(node), phandle_name,
|
||||||
|
index);
|
||||||
|
if (!np)
|
||||||
|
return ofnode_null();
|
||||||
|
|
||||||
|
phandle = np_to_ofnode(np);
|
||||||
|
} else {
|
||||||
|
struct fdtdec_phandle_args args;
|
||||||
|
|
||||||
|
if (fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),
|
||||||
|
ofnode_to_offset(node),
|
||||||
|
phandle_name, NULL,
|
||||||
|
0, index, &args))
|
||||||
|
return ofnode_null();
|
||||||
|
|
||||||
|
phandle = offset_to_ofnode(args.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return phandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
ofnode oftree_parse_phandle(oftree tree, ofnode node, const char *phandle_name,
|
||||||
|
int index)
|
||||||
|
{
|
||||||
|
ofnode phandle;
|
||||||
|
|
||||||
|
if (ofnode_is_np(node)) {
|
||||||
|
struct device_node *np;
|
||||||
|
|
||||||
|
np = of_root_parse_phandle(tree.np, ofnode_to_np(node),
|
||||||
|
phandle_name, index);
|
||||||
|
if (!np)
|
||||||
|
return ofnode_null();
|
||||||
|
|
||||||
|
phandle = np_to_ofnode(np);
|
||||||
|
} else {
|
||||||
|
struct fdtdec_phandle_args args;
|
||||||
|
|
||||||
|
if (fdtdec_parse_phandle_with_args(tree.fdt,
|
||||||
|
ofnode_to_offset(node),
|
||||||
|
phandle_name, NULL,
|
||||||
|
0, index, &args))
|
||||||
|
return ofnode_null();
|
||||||
|
|
||||||
|
phandle = noffset_to_ofnode(node, args.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return phandle;
|
||||||
|
}
|
||||||
|
|
||||||
static void ofnode_from_fdtdec_phandle_args(ofnode node, struct fdtdec_phandle_args *in,
|
static void ofnode_from_fdtdec_phandle_args(ofnode node, struct fdtdec_phandle_args *in,
|
||||||
struct ofnode_phandle_args *out)
|
struct ofnode_phandle_args *out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -847,6 +847,18 @@ int ofnode_read_string_count(ofnode node, const char *property);
|
||||||
int ofnode_read_string_list(ofnode node, const char *property,
|
int ofnode_read_string_list(ofnode node, const char *property,
|
||||||
const char ***listp);
|
const char ***listp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ofnode_parse_phandle() - Resolve a phandle property to an ofnode
|
||||||
|
*
|
||||||
|
* @node: node to check
|
||||||
|
* @phandle_name: Name of property holding a phandle value
|
||||||
|
* @index: For properties holding a table of phandles, this is the index into
|
||||||
|
* the table
|
||||||
|
* Return: ofnode that the phandle points to or ofnode_null() on error.
|
||||||
|
*/
|
||||||
|
ofnode ofnode_parse_phandle(ofnode node, const char *phandle_name,
|
||||||
|
int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ofnode_parse_phandle_with_args() - Find a node pointed by phandle in a list
|
* ofnode_parse_phandle_with_args() - Find a node pointed by phandle in a list
|
||||||
*
|
*
|
||||||
|
@ -909,6 +921,20 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
|
||||||
int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
|
int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
|
||||||
const char *cells_name, int cell_count);
|
const char *cells_name, int cell_count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oftree_parse_phandle() - Resolve a phandle property to an ofnode
|
||||||
|
* from a root node
|
||||||
|
*
|
||||||
|
* @tree: device tree to use
|
||||||
|
* @node: node to check
|
||||||
|
* @phandle_name: Name of property holding a phandle value
|
||||||
|
* @index: For properties holding a table of phandles, this is the index into
|
||||||
|
* the table
|
||||||
|
* Return: ofnode that the phandle points to or ofnode_null() on error.
|
||||||
|
*/
|
||||||
|
ofnode oftree_parse_phandle(oftree tree, ofnode node, const char *phandle_name,
|
||||||
|
int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oftree_parse_phandle_with_args() - Find a node pointed by phandle in a list
|
* oftree_parse_phandle_with_args() - Find a node pointed by phandle in a list
|
||||||
* from a root node
|
* from a root node
|
||||||
|
|
Loading…
Add table
Reference in a new issue