diff options
author | Simon Glass <sjg@chromium.org> | 2023-09-26 08:14:43 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-06 14:38:13 -0400 |
commit | 62b1db33778611a3023d1e3a98e869b495edc9ca (patch) | |
tree | a02bcbcf8555af6897638135af9662a53ff591af /include | |
parent | 67fb2159fb3438359fa0fc3f8cb491ffe8d57c0f (diff) | |
download | u-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')
-rw-r--r-- | include/dm/ofnode.h | 13 | ||||
-rw-r--r-- | include/of_live.h | 10 |
2 files changed, 23 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. diff --git a/include/of_live.h b/include/of_live.h index 81cb9bd..67bd5f0 100644 --- a/include/of_live.h +++ b/include/of_live.h @@ -9,6 +9,7 @@ #ifndef _OF_LIVE_H #define _OF_LIVE_H +struct abuf; struct device_node; /** @@ -54,4 +55,13 @@ void of_live_free(struct device_node *root); */ int of_live_create_empty(struct device_node **rootp); +/** + * of_live_flatten() - Create an FDT from a hierarchical tree + * + * @root: Root node of tree to convert + * @buf: Buffer to return the tree (inited by this function) + * Return: 0 if OK, -ENOMEM if out of memory + */ +int of_live_flatten(const struct device_node *root, struct abuf *buf); + #endif |