dm: core: Add a way to look up a phandle in an oftree

When we have multiple trees, the ofnode logic needs to be told which one
to use. Create a new function which takes an oftree argument, along with
a helper to obtain the FDT pointer from an oftree.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 48d4dec..012cb8c 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -410,6 +410,20 @@
 	return node;
 }
 
+ofnode oftree_get_by_phandle(oftree tree, uint phandle)
+{
+	ofnode node;
+
+	if (of_live_active())
+		node = np_to_ofnode(of_find_node_by_phandle(tree.np, phandle));
+	else
+		node.of_offset =
+			fdt_node_offset_by_phandle(oftree_lookup_fdt(tree),
+						   phandle);
+
+	return node;
+}
+
 static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
 					       fdt_size_t *size, bool translate)
 {