Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
[platform/kernel/u-boot.git] / lib_ppc / bootm.c
index 86e104c..9194fd8 100644 (file)
@@ -23,7 +23,6 @@
  * MA 02111-1307 USA
  */
 
-#define DEBUG
 
 #include <common.h>
 #include <watchdog.h>
@@ -147,7 +146,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                ret = fit_image_get_entry (images->fit_hdr_os,
@@ -185,18 +184,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                        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);
@@ -311,7 +298,7 @@ static void set_clocks_in_mhz (bd_t *kbd)
                kbd->bi_cpmfreq /= 1000000L;
                kbd->bi_brgfreq /= 1000000L;
                kbd->bi_sccfreq /= 1000000L;
-               kbd->bi_vco     /= 1000000L;
+               kbd->bi_vco     /= 1000000L;
 #endif
 #if defined(CONFIG_MPC5xxx)
                kbd->bi_ipbfreq /= 1000000L;
@@ -411,11 +398,11 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
        ulong           image_start, image_end;
        ulong           load_start, load_end;
 #if defined(CONFIG_FIT)
-        void            *fit_hdr;
-        const char      *fit_uname_config = NULL;
-        const char      *fit_uname_fdt = NULL;
+       void            *fit_hdr;
+       const char      *fit_uname_config = NULL;
+       const char      *fit_uname_fdt = NULL;
        ulong           default_addr;
-       int             conf_noffset;
+       int             cfg_noffset;
        int             fdt_noffset;
        const void      *data;
        size_t          size;
@@ -424,35 +411,67 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
        *of_flat_tree = NULL;
        *of_size = 0;
 
-       if (argc > 3) {
+       if (argc > 3 || genimg_has_config (images)) {
 #if defined(CONFIG_FIT)
-               /*
-                * If the FDT blob comes from the FIT image and the FIT image
-                * address is omitted in the command line argument, try to use
-                * ramdisk or os FIT image address or default load address.
-                */
-               if (images->fit_uname_rd)
-                       default_addr = (ulong)images->fit_hdr_rd;
-               else if (images->fit_uname_os)
-                       default_addr = (ulong)images->fit_hdr_os;
-               else
-                       default_addr = load_addr;
-
-               if (fit_parse_conf (argv[3], default_addr,
-                                       &fdt_addr, &fit_uname_config)) {
-                       debug ("*  fdt: config '%s' from image at 0x%08lx\n",
-                                       fit_uname_config, fdt_addr);
-               } else if (fit_parse_subimage (argv[3], default_addr,
-                                       &fdt_addr, &fit_uname_fdt)) {
-                       debug ("*  fdt: subimage '%s' from image at 0x%08lx\n",
-                                       fit_uname_fdt, fdt_addr);
-               } else
+               if (argc > 3) {
+                       /*
+                        * If the FDT blob comes from the FIT image and the
+                        * FIT image address is omitted in the command line
+                        * argument, try to use ramdisk or os FIT image
+                        * address or default load address.
+                        */
+                       if (images->fit_uname_rd)
+                               default_addr = (ulong)images->fit_hdr_rd;
+                       else if (images->fit_uname_os)
+                               default_addr = (ulong)images->fit_hdr_os;
+                       else
+                               default_addr = load_addr;
+
+                       if (fit_parse_conf (argv[3], default_addr,
+                                               &fdt_addr, &fit_uname_config)) {
+                               debug ("*  fdt: config '%s' from image at 0x%08lx\n",
+                                               fit_uname_config, fdt_addr);
+                       } else if (fit_parse_subimage (argv[3], default_addr,
+                                               &fdt_addr, &fit_uname_fdt)) {
+                               debug ("*  fdt: subimage '%s' from image at 0x%08lx\n",
+                                               fit_uname_fdt, fdt_addr);
+                       } else
 #endif
-               {
-                       fdt_addr = simple_strtoul(argv[3], NULL, 16);
-                       debug ("*  fdt: cmdline image address = 0x%08lx\n",
-                                       fdt_addr);
+                       {
+                               fdt_addr = simple_strtoul(argv[3], NULL, 16);
+                               debug ("*  fdt: cmdline image address = 0x%08lx\n",
+                                               fdt_addr);
+                       }
+#if defined(CONFIG_FIT)
+               } else {
+                       /* use FIT configuration provided in first bootm
+                        * command argument
+                        */
+                       fdt_addr = (ulong)images->fit_hdr_os;
+                       fit_uname_config = images->fit_uname_cfg;
+                       debug ("*  fdt: using config '%s' from image at 0x%08lx\n",
+                                       fit_uname_config, fdt_addr);
+
+                       /*
+                        * Check whether configuration has FDT blob defined,
+                        * if not quit silently.
+                        */
+                       fit_hdr = (void *)fdt_addr;
+                       cfg_noffset = fit_conf_get_node (fit_hdr,
+                                       fit_uname_config);
+                       if (cfg_noffset < 0) {
+                               debug ("*  fdt: no such config\n");
+                               return 0;
+                       }
+
+                       fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
+                                       cfg_noffset);
+                       if (fdt_noffset < 0) {
+                               debug ("*  fdt: no fdt in config\n");
+                               return 0;
+                       }
                }
+#endif
 
                debug ("## Checking for 'FDT'/'FDT Image' at %08lx\n",
                                fdt_addr);
@@ -522,13 +541,21 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                                         * fit_conf_get_node() will try to
                                         * find default config node
                                         */
-                                       conf_noffset = fit_conf_get_node (fit_hdr,
+                                       cfg_noffset = fit_conf_get_node (fit_hdr,
                                                        fit_uname_config);
-                                       if (conf_noffset < 0)
+
+                                       if (cfg_noffset < 0) {
+                                               fdt_error ("Could not find configuration node\n");
                                                goto error;
+                                       }
+
+                                       fit_uname_config = fdt_get_name (fit_hdr,
+                                                       cfg_noffset, NULL);
+                                       printf ("   Using '%s' configuration\n",
+                                                       fit_uname_config);
 
                                        fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
-                                                       conf_noffset);
+                                                       cfg_noffset);
                                        fit_uname_fdt = fit_get_name (fit_hdr,
                                                        fdt_noffset, NULL);
                                } else {
@@ -536,8 +563,10 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                                        fdt_noffset = fit_image_get_node (fit_hdr,
                                                        fit_uname_fdt);
                                }
-                               if (fdt_noffset < 0)
+                               if (fdt_noffset < 0) {
+                                       fdt_error ("Could not find subimage node\n");
                                        goto error;
+                               }
 
                                printf ("   Trying '%s' FDT blob subimage\n",
                                                fit_uname_fdt);
@@ -597,9 +626,9 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                                /*
                                 * FDT blob
                                 */
+                               fdt_blob = (char *)fdt_addr;
                                debug ("*  fdt: raw FDT blob\n");
                                printf ("## Flattened Device Tree blob at %08lx\n", fdt_blob);
-                               fdt_blob = (char *)fdt_addr;
                        }
                        break;
                default:
@@ -610,7 +639,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                printf ("   Booting using the fdt blob at 0x%x\n", fdt_blob);
 
        } else if (images->legacy_hdr_valid &&
-                       image_check_type (images->legacy_hdr_os, IH_TYPE_MULTI)) {
+                       image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
 
                ulong fdt_data, fdt_len;
 
@@ -638,9 +667,8 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                                goto error;
                        }
                } else {
-                       fdt_error ("Did not find a Flattened Device Tree "
-                               "in a legacy multi-component image");
-                       goto error;
+                       debug ("## No Flattened Device Tree\n");
+                       return 0;
                }
        } else {
                debug ("## No Flattened Device Tree\n");