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>
This commit is contained in:
Simon Glass
2022-09-06 20:27:20 -06:00
committed by Tom Rini
parent ee88ba71ac
commit a3f50d0386
2 changed files with 69 additions and 41 deletions

View File

@@ -35,6 +35,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
*