Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 8b50d52 | 2017-05-18 20:08:55 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2017 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | * |
Simon Glass | 8b50d52 | 2017-05-18 20:08:55 -0600 | [diff] [blame] | 6 | * Support for a 'live' (as opposed to flat) device tree |
| 7 | */ |
| 8 | |
| 9 | #ifndef _OF_LIVE_H |
| 10 | #define _OF_LIVE_H |
| 11 | |
Simon Glass | 62b1db3 | 2023-09-26 08:14:43 -0600 | [diff] [blame] | 12 | struct abuf; |
Simon Glass | 8b50d52 | 2017-05-18 20:08:55 -0600 | [diff] [blame] | 13 | struct device_node; |
| 14 | |
| 15 | /** |
| 16 | * of_live_build() - build a live (hierarchical) tree from a flat DT |
| 17 | * |
| 18 | * @fdt_blob: Input tree to convert |
| 19 | * @rootp: Returns live tree that was created |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 20 | * Return: 0 if OK, -ve on error |
Simon Glass | 8b50d52 | 2017-05-18 20:08:55 -0600 | [diff] [blame] | 21 | */ |
| 22 | int of_live_build(const void *fdt_blob, struct device_node **rootp); |
| 23 | |
Simon Glass | 3310484 | 2022-07-30 15:52:08 -0600 | [diff] [blame] | 24 | /** |
| 25 | * unflatten_device_tree() - create tree of device_nodes from flat blob |
| 26 | * |
| 27 | * Note that this allocates a single block of memory, pointed to by *mynodes. |
| 28 | * To free the tree, use free(*mynodes) |
| 29 | * |
| 30 | * unflattens a device-tree, creating the |
| 31 | * tree of struct device_node. It also fills the "name" and "type" |
| 32 | * pointers of the nodes so the normal device-tree walking functions |
| 33 | * can be used. |
| 34 | * @blob: The blob to expand |
| 35 | * @mynodes: The device_node tree created by the call |
| 36 | * Return: 0 if OK, -ve on error |
| 37 | */ |
| 38 | int unflatten_device_tree(const void *blob, struct device_node **mynodes); |
| 39 | |
Simon Glass | a8f2ac2 | 2023-06-01 10:22:42 -0600 | [diff] [blame] | 40 | /** |
| 41 | * of_live_free() - Dispose of a livetree |
| 42 | * |
| 43 | * This frees memory used by the tree, after which @root becomes invalid and |
| 44 | * cannot be used |
| 45 | * |
| 46 | * @root: Tree to dispose |
| 47 | */ |
| 48 | void of_live_free(struct device_node *root); |
| 49 | |
Simon Glass | e0c3c21 | 2023-09-26 08:14:40 -0600 | [diff] [blame] | 50 | /** |
| 51 | * of_live_create_empty() - Create a new, empty tree |
| 52 | * |
| 53 | * @rootp: Returns the root node of the created tree |
| 54 | * Return: 0 if OK, -ENOMEM if out of memory |
| 55 | */ |
| 56 | int of_live_create_empty(struct device_node **rootp); |
| 57 | |
Simon Glass | 62b1db3 | 2023-09-26 08:14:43 -0600 | [diff] [blame] | 58 | /** |
| 59 | * of_live_flatten() - Create an FDT from a hierarchical tree |
| 60 | * |
| 61 | * @root: Root node of tree to convert |
| 62 | * @buf: Buffer to return the tree (inited by this function) |
| 63 | * Return: 0 if OK, -ENOMEM if out of memory |
| 64 | */ |
| 65 | int of_live_flatten(const struct device_node *root, struct abuf *buf); |
| 66 | |
Simon Glass | 8b50d52 | 2017-05-18 20:08:55 -0600 | [diff] [blame] | 67 | #endif |