dm: core: Add a way to convert a devicetree to a dtb
Add a way to flatten a devicetree into binary form. For livetree this involves generating the devicetree using fdt_property() and other calls. For flattree it simply involves providing the buffer containing the tree. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -243,6 +243,24 @@ int oftree_new(oftree *treep)
|
||||
|
||||
#endif /* OFNODE_MULTI_TREE */
|
||||
|
||||
int oftree_to_fdt(oftree tree, struct abuf *buf)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (of_live_active()) {
|
||||
ret = of_live_flatten(ofnode_to_np(oftree_root(tree)), buf);
|
||||
if (ret)
|
||||
return log_msg_ret("flt", ret);
|
||||
} else {
|
||||
void *fdt = oftree_lookup_fdt(tree);
|
||||
|
||||
abuf_init(buf);
|
||||
abuf_set(buf, fdt, fdt_totalsize(fdt));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ofnode_from_tree_offset() - get an ofnode from a tree offset (flat tree)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user