 -	} else {
 -		create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
 -	}
- 
+-
 -	if (arch_options.initrd_file) {
 -		initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
+ 
+-		/* Create initrd entries in dtb - although at this time
+-		 * they would not point to the correct location */
+-		dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + initrd_size);
+-
+-		initrd_base = add_buffer(info, initrd_buf, initrd_size,
+-					initrd_size, sizeof(void *),
+-					_ALIGN_UP(kernel_addr + kernel_size + dtb_length,
+-						pagesize), 0x0fffffff, 1);
+-
+-		/* Now that the buffer for initrd is prepared, update the dtb
+-		 * with an appropriate location */
+-		dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
 +	if (!arch_options.no_dtb) {
 +		/* MIPS systems that have been converted to use device tree
 +		 * passed through UHI will use commandline in the DTB and

 	);
 }
 
@@ -121,6 +122,9 @@ int arch_process_options(int argc, char **argv)
 		case OPT_RAMDISK:
 			arch_options.initrd_file = optarg;
 			break;

+		} else {
+			create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
+		}
+
+		if (arch_options.initrd_file) {
+			initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
+
+			/* Create initrd entries in dtb - although at this time
+			 * they would not point to the correct location */
+			dtb_set_initrd(&dtb_buf, &dtb_length, (off_t)initrd_buf, (off_t)initrd_buf + initrd_size);
+
+			initrd_base = add_buffer(info, initrd_buf, initrd_size,
+						initrd_size, sizeof(void *),
+						_ALIGN_UP(kernel_addr + kernel_size + dtb_length,
+							pagesize), 0x0fffffff, 1);
+
+			/* Now that the buffer for initrd is prepared, update the dtb
+			 * with an appropriate location */
+			dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
+		}
 	}
 
-
 	/* This is a legacy method for commandline passing used
 	 * currently by Octeon CPUs only */
 	add_buffer(info, cmdline_buf, sizeof(cmdline_buf),
 			sizeof(cmdline_buf), sizeof(void *),
 			cmdline_addr, 0x0fffffff, 1);
 
