aboutsummaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass2022-09-06 20:27:20 -0600
committerTom Rini2022-09-29 22:43:43 -0400
commita3f50d038695887808497c1a15c9fcc122d964e6 (patch)
tree2225917b6f2ec9a504152470753b1deb81ef72e6 /include/dm
parentee88ba71acce3455aadef18c725de715e6c9af21 (diff)
dm: core: Add an ofnode function to obtain the flat tree
The flat device tree is assumed to be the control FDT but this is not always the case. Update the ofnode implementation to obtain the node via an function call so we can eventually add support for selecting different trees. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/ofnode.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 7e9d3be96a2..f68896711e5 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -36,6 +36,25 @@ struct ofnode_phandle_args {
static inline void oftree_reset(void) {}
/**
+ * ofnode_to_fdt() - convert an ofnode to a flat DT pointer
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be NULL)
+ */
+static inline void *ofnode_to_fdt(ofnode node)
+{
+#ifdef OF_CHECKS
+ if (of_live_active())
+ return NULL;
+#endif
+
+ /* Use the control FDT by default */
+ return (void *)gd->fdt_blob;
+}
+
+/**
* ofnode_to_np() - convert an ofnode to a live DT node pointer
*
* This cannot be called if the reference contains an offset.