Merge branch 'master' of git://git.denx.de/u-boot-spi
[oweals/u-boot.git] / drivers / core / util.c
index 451d4766d08c7a9db25da13f54f9fa6af52ede1d..27a68487034e182331ece2ed2244ebf685bd5a79 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <dm/ofnode.h>
 #include <dm/util.h>
 #include <linux/libfdt.h>
 #include <vsprintf.h>
@@ -53,3 +54,27 @@ bool dm_fdt_pre_reloc(const void *blob, int offset)
 
        return false;
 }
+
+bool dm_ofnode_pre_reloc(ofnode node)
+{
+       if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
+               return true;
+
+#ifdef CONFIG_TPL_BUILD
+       if (ofnode_read_bool(node, "u-boot,dm-tpl"))
+               return true;
+#elif defined(CONFIG_SPL_BUILD)
+       if (ofnode_read_bool(node, "u-boot,dm-spl"))
+               return true;
+#else
+       /*
+        * In regular builds individual spl and tpl handling both
+        * count as handled pre-relocation for later second init.
+        */
+       if (ofnode_read_bool(node, "u-boot,dm-spl") ||
+           ofnode_read_bool(node, "u-boot,dm-tpl"))
+               return true;
+#endif
+
+       return false;
+}