]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
8b50d526 SG |
2 | /* |
3 | * Copyright (c) 2017 Google, Inc | |
4 | * Written by Simon Glass <[email protected]> | |
5 | * | |
8b50d526 SG |
6 | * Support for a 'live' (as opposed to flat) device tree |
7 | */ | |
8 | ||
9 | #ifndef _OF_LIVE_H | |
10 | #define _OF_LIVE_H | |
11 | ||
62b1db33 | 12 | struct abuf; |
8b50d526 SG |
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 | |
185f812c | 20 | * Return: 0 if OK, -ve on error |
8b50d526 SG |
21 | */ |
22 | int of_live_build(const void *fdt_blob, struct device_node **rootp); | |
23 | ||
33104847 SG |
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 | ||
a8f2ac2a SG |
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 | ||
e0c3c21d SG |
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 | ||
62b1db33 SG |
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 | ||
8b50d526 | 67 | #endif |