+ /*
+ * Add the chosen node if it doesn't exist, add the env and bd_t
+ * if the user wants it (the logic is in the subroutines).
+ */
+ if (of_size) {
+ /* pass in dummy initrd info, we'll fix up later */
+ if (fdt_chosen(of_flat_tree, rd_data_start, rd_data_end, 0) < 0) {
+ fdt_error ("/chosen node create failed");
+ goto error;
+ }
+#ifdef CONFIG_OF_HAS_UBOOT_ENV
+ if (fdt_env(of_flat_tree) < 0) {
+ fdt_error ("/u-boot-env node create failed");
+ goto error;
+ }
+#endif
+#ifdef CONFIG_OF_HAS_BD_T
+ if (fdt_bd_t(of_flat_tree) < 0) {
+ fdt_error ("/bd_t node create failed");
+ goto error;
+ }
+#endif
+#ifdef CONFIG_OF_BOARD_SETUP
+ /* Call the board-specific fixup routine */
+ ft_board_setup(of_flat_tree, gd->bd);
+#endif
+ }
+#endif /* CONFIG_OF_LIBFDT */
+
+ ret = ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end);
+ if (ret)
+ goto error;
+
+#if defined(CONFIG_OF_LIBFDT)
+ /* fixup the initrd now that we know where it should be */
+ if ((of_flat_tree) && (initrd_start && initrd_end)) {
+ uint64_t addr, size;
+ int total = fdt_num_mem_rsv(of_flat_tree);
+ int j;
+
+ /* Look for the dummy entry and delete it */
+ for (j = 0; j < total; j++) {
+ fdt_get_mem_rsv(of_flat_tree, j, &addr, &size);
+ if (addr == rd_data_start) {
+ fdt_del_mem_rsv(of_flat_tree, j);
+ break;
+ }
+ }
+
+ ret = fdt_add_mem_rsv(of_flat_tree, initrd_start,
+ initrd_end - initrd_start + 1);
+ if (ret < 0) {
+ printf("fdt_chosen: %s\n", fdt_strerror(ret));
+ goto error;
+ }
+
+ do_fixup_by_path_u32(of_flat_tree, "/chosen",
+ "linux,initrd-start", initrd_start, 0);
+ do_fixup_by_path_u32(of_flat_tree, "/chosen",
+ "linux,initrd-end", initrd_end, 0);
+ }
+#endif
+ debug ("## Transferring control to Linux (at address %08lx) ...\n",
+ (ulong)kernel);
+
+ show_boot_progress (15);
+
+#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
+ unlock_ram_in_cache();