]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - libfdt/fdt_wip.c
Merge with git://www.denx.de/git/u-boot.git
[karo-tx-uboot.git] / libfdt / fdt_wip.c
index 261b9b0dc9379f714fd00ea2a0806d065a269336..2d39aabe1fe9872c2a9e5e441979426244e063fd 100644 (file)
@@ -16,6 +16,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
+#include "config.h"
+#if CONFIG_OF_LIBFDT
+
 #include "libfdt_env.h"
 
 #include <fdt.h>
@@ -110,3 +113,30 @@ int fdt_nop_node(void *fdt, int nodeoffset)
        nop_region(fdt_offset_ptr(fdt, nodeoffset, 0), endoffset - nodeoffset);
        return 0;
 }
+
+/*
+ * Replace a reserve map entry in the nth slot.
+ */
+int fdt_replace_reservemap_entry(void *fdt, int n, uint64_t addr, uint64_t size)
+{
+       struct fdt_reserve_entry *re;
+       int  used;
+       int  total;
+       int  err;
+
+       err = fdt_num_reservemap(fdt, &used, &total);
+       if (err != 0)
+               return err;
+
+       if (n >= total)
+               return -FDT_ERR_NOSPACE;
+       re = (struct fdt_reserve_entry *)
+               (fdt + fdt_off_mem_rsvmap(fdt) +
+                (n * sizeof(struct fdt_reserve_entry)));
+       re->address = cpu_to_fdt64(addr);
+       re->size    = cpu_to_fdt64(size);
+
+       return 0;
+}
+
+#endif /* CONFIG_OF_LIBFDT */