summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-05-03 18:13:53 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-06-04 11:22:57 +0000
commit6702b68a7966d584e310bf7a99f4a1dc57f2f56f (patch)
treeb04b8d7a658d79e4c0c07575eac9c26c36c51962 /src/include
parent73eaec81689662cf5c1cd6ac5de1152e19b0c14d (diff)
device_tree: Add phandle caching and lookups
This patch caches phandles when unflattening the device tree, so we don't have to look up the phandle property again every time we're trying to find the phandle of a node. This is especially important when supporting phandle lookups, which are also added. In addition we keep track of the highest phandle in the whole tree, which will be important for applying overlays later. With this, dt_get_phandle(node) becomes obsolete because the phandle is already available as a member variable in the node. This patch was adapted from depthcharge's http://crosreview.com/1536385 Change-Id: I9cbd67d1d13e57c25d068b3db18bb75c709d7ebe Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32863 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/device_tree.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/include/device_tree.h b/src/include/device_tree.h
index 96902b893b..8280dad077 100644
--- a/src/include/device_tree.h
+++ b/src/include/device_tree.h
@@ -47,6 +47,7 @@ struct fdt_header {
#define FDT_TOKEN_END_NODE 2
#define FDT_TOKEN_PROPERTY 3
#define FDT_TOKEN_END 9
+#define FDT_PHANDLE_ILLEGAL 0xdeadbeef
struct fdt_property
{
@@ -71,6 +72,8 @@ struct device_tree_property
struct device_tree_node
{
const char *name;
+ uint32_t phandle;
+
// List of struct device_tree_property-s.
struct list_node properties;
// List of struct device_tree_nodes.
@@ -91,6 +94,7 @@ struct device_tree
{
const void *header;
uint32_t header_size;
+ uint32_t max_phandle;
struct list_node reserve_map;
@@ -136,6 +140,8 @@ void dt_read_cell_props(const struct device_tree_node *node, u32 *addrcp,
// represented as an array of strings.
struct device_tree_node *dt_find_node(struct device_tree_node *parent, const char **path,
u32 *addrcp, u32 *sizecp, int create);
+struct device_tree_node *dt_find_node_by_phandle(struct device_tree_node *root,
+ uint32_t phandle);
// Look up or create a node relative to a parent node, through its path
// represented as a string of '/' separated node names.
struct device_tree_node *dt_find_node_by_path(struct device_tree_node *parent, const char *path,
@@ -150,8 +156,6 @@ struct device_tree_node *dt_find_next_compat_child(struct device_tree_node *pare
// Look up a node relative to a parent node, through its property value.
struct device_tree_node *dt_find_prop_value(struct device_tree_node *parent, const char *name,
void *data, size_t size);
-// Return the phandle
-uint32_t dt_get_phandle(const struct device_tree_node *node);
// Write src into *dest as a 'length'-byte big-endian integer.
void dt_write_int(u8 *dest, u64 src, size_t length);
// Delete a property