diff options
author | Simon Glass | 2023-09-26 08:14:43 -0600 |
---|---|---|
committer | Tom Rini | 2023-10-06 14:38:13 -0400 |
commit | 62b1db33778611a3023d1e3a98e869b495edc9ca (patch) | |
tree | a02bcbcf8555af6897638135af9662a53ff591af /drivers/core | |
parent | 67fb2159fb3438359fa0fc3f8cb491ffe8d57c0f (diff) |
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>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/ofnode.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index a5efedf6af3..39ba480c8f8 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -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) * |