aboutsummaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-09-26 08:14:43 -0600
committerTom Rini <trini@konsulko.com>2023-10-06 14:38:13 -0400
commit62b1db33778611a3023d1e3a98e869b495edc9ca (patch)
treea02bcbcf8555af6897638135af9662a53ff591af /include/dm
parent67fb2159fb3438359fa0fc3f8cb491ffe8d57c0f (diff)
downloadu-boot-62b1db33778611a3023d1e3a98e869b495edc9ca.zip
u-boot-62b1db33778611a3023d1e3a98e869b495edc9ca.tar.gz
u-boot-62b1db33778611a3023d1e3a98e869b495edc9ca.tar.bz2
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 'include/dm')
-rw-r--r--include/dm/ofnode.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index f1ee02c..a8605fb 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -17,6 +17,7 @@
/* Enable checks to protect against invalid calls */
#undef OF_CHECKS
+struct abuf;
struct resource;
#include <dm/ofnode_decl.h>
@@ -137,6 +138,18 @@ static inline ofnode noffset_to_ofnode(ofnode other_node, int of_offset)
int oftree_new(oftree *treep);
/**
+ * oftree_to_fdt() - Convert an oftree to a flat FDT
+ *
+ * @tree: tree to flatten (if livetree) or copy (if not)
+ * @buf: Returns inited buffer containing the newly created flat tree. Note
+ * that for flat tree the buffer is not allocated. In either case the caller
+ * must call abut_uninit() to free any memory used by @buf
+ * Return: 0 on success, -ENOMEM if out of memory, other -ve value for any other
+ * error
+ */
+int oftree_to_fdt(oftree tree, struct abuf *buf);
+
+/**
* ofnode_to_np() - convert an ofnode to a live DT node pointer
*
* This cannot be called if the reference contains an offset.