rockchip: Add support for the SPI image
[pandora-u-boot.git] / common / image.c
index 9efacf8..1325e07 100644 (file)
@@ -54,6 +54,10 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 #include <u-boot/md5.h>
 #include <time.h>
 #include <image.h>
+
+#ifndef __maybe_unused
+# define __maybe_unused                /* unimplemented */
+#endif
 #endif /* !USE_HOSTCC*/
 
 #include <u-boot/crc.h>
@@ -151,6 +155,9 @@ static const table_entry_t uimage_type[] = {
        {       IH_TYPE_ATMELIMAGE, "atmelimage", "ATMEL ROM-Boot Image",},
        {       IH_TYPE_X86_SETUP,  "x86_setup",  "x86 setup.bin",    },
        {       IH_TYPE_LPC32XXIMAGE, "lpc32xximage",  "LPC32XX Boot Image", },
+       {       IH_TYPE_RKIMAGE,    "rkimage",    "Rockchip Boot Image" },
+       {       IH_TYPE_RKSD,       "rksd",       "Rockchip SD Boot Image" },
+       {       IH_TYPE_RKSPI,      "rkspi",      "Rockchip SPI Boot Image" },
        {       -1,                 "",           "",                   },
 };
 
@@ -274,7 +281,7 @@ void image_multi_getimg(const image_header_t *hdr, ulong idx,
 
 static void image_print_type(const image_header_t *hdr)
 {
-       const char *os, *arch, *type, *comp;
+       const char __maybe_unused *os, *arch, *type, *comp;
 
        os = genimg_get_os_name(image_get_os(hdr));
        arch = genimg_get_arch_name(image_get_arch(hdr));
@@ -299,7 +306,7 @@ static void image_print_type(const image_header_t *hdr)
 void image_print_contents(const void *ptr)
 {
        const image_header_t *hdr = (const image_header_t *)ptr;
-       const char *p;
+       const char __maybe_unused *p;
 
        p = IMAGE_INDENT_STRING;
        printf("%sImage Name:   %.*s\n", p, IH_NMLEN, image_get_name(hdr));
@@ -902,6 +909,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 
        if (argc >= 2)
                select = argv[1];
+
        /*
         * Look for a '-' which indicates to ignore the
         * ramdisk argument
@@ -1000,6 +1008,12 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                        images->fit_uname_rd = fit_uname_ramdisk;
                        images->fit_noffset_rd = rd_noffset;
                        break;
+#endif
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+               case IMAGE_FORMAT_ANDROID:
+                       android_image_get_ramdisk((void *)images->os.start,
+                               &rd_data, &rd_len);
+                       break;
 #endif
                default:
 #ifdef CONFIG_SUPPORT_RAW_INITRD
@@ -1031,16 +1045,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                                (ulong)images->legacy_hdr_os);
 
                image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len);
-       }
-#ifdef CONFIG_ANDROID_BOOT_IMAGE
-       else if ((genimg_get_format((void *)images->os.start)
-                       == IMAGE_FORMAT_ANDROID) &&
-                (!android_image_get_ramdisk((void *)images->os.start,
-                &rd_data, &rd_len))) {
-               /* empty */
-       }
-#endif
-       else {
+       } else {
                /*
                 * no initrd image
                 */
@@ -1213,10 +1218,10 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
                conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
 
                for (loadables_index = 0;
-                    !fdt_get_string_index(buf, conf_noffset,
+                    fdt_get_string_index(buf, conf_noffset,
                                FIT_LOADABLE_PROP,
                                loadables_index,
-                               (const char **)&uname) > 0;
+                               (const char **)&uname) == 0;
                     loadables_index++)
                {
                        fit_img_result = fit_image_load(images,