#include <linux/types.h>
 #include <linux/init.h>
 #include <linux/mm.h>
+#include <linux/memblock.h>
 
 #include <asm/bootinfo.h>
 
 
 void __init plat_swiotlb_setup(void)
 {
-       int i;
+       struct memblock_region *mem;
        phys_addr_t max_addr;
        phys_addr_t addr_size;
        size_t swiotlbsize;
        max_addr = 0;
        addr_size = 0;
 
-       for (i = 0 ; i < boot_mem_map.nr_map; i++) {
-               struct boot_mem_map_entry *e = &boot_mem_map.map[i];
-               if (e->type != BOOT_MEM_RAM && e->type != BOOT_MEM_INIT_RAM)
-                       continue;
-
+       for_each_memblock(memory, mem) {
                /* These addresses map low for PCI. */
-               if (e->addr > 0x410000000ull && !OCTEON_IS_OCTEON2())
+               if (mem->base > 0x410000000ull && !OCTEON_IS_OCTEON2())
                        continue;
 
-               addr_size += e->size;
+               addr_size += mem->size;
 
-               if (max_addr < e->addr + e->size)
-                       max_addr = e->addr + e->size;
+               if (max_addr < mem->base + mem->size)
+                       max_addr = mem->base + mem->size;
 
        }
 
 
         * regions next to each other.
         */
        cvmx_bootmem_lock();
-       while ((boot_mem_map.nr_map < BOOT_MEM_MAP_MAX)
-               && (total < max_memory)) {
+       while (total < max_memory) {
                memory = cvmx_bootmem_phy_alloc(mem_alloc_size,
                                                __pa_symbol(&_end), -1,
                                                0x100000,