]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib/fdtdec.c
Merge branch 'next'
[karo-tx-uboot.git] / lib / fdtdec.c
index 33265ecfb26cb3d378dc78141f1fd4680b0efe0b..8ecb80f1623bfb95ca02ee8c4be133818be0b87d 100644 (file)
@@ -3,6 +3,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#ifndef USE_HOSTCC
 #include <common.h>
 #include <serial.h>
 #include <libfdt.h>
@@ -645,3 +646,22 @@ int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
 
        return 0;
 }
+#else
+#include "libfdt.h"
+#include "fdt_support.h"
+
+int fdtdec_get_int(const void *blob, int node, const char *prop_name,
+               int default_val)
+{
+       const int *cell;
+       int len;
+
+       cell = fdt_getprop_w((void *)blob, node, prop_name, &len);
+       if (cell && len >= sizeof(int)) {
+               int val = fdt32_to_cpu(cell[0]);
+
+               return val;
+       }
+       return default_val;
+}
+#endif