bootm: make use of legacy image format configurable

make the use of legacy image format configurable through
the config define CONFIG_IMAGE_FORMAT_LEGACY.

When relying on signed FIT images with required signature check
the legacy image format should be disabled. Therefore introduce
this new define and enable legacy image format if CONFIG_FIT_SIGNATURE
is not set. If CONFIG_FIT_SIGNATURE is set disable per default
the legacy image format.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Lars Steubesand <lars.steubesand@philips.com>
Cc: Mike Pearce <mike@kaew.be>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Tom Rini <trini@ti.com>
Cc: Michal Simek <monstr@monstr.eu>
Acked-by: Simon Glass <sjg@chromium.org>
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 449bb36..9b11c0e 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -230,6 +230,7 @@
 
 	/* get image parameters */
 	switch (genimg_get_format(os_hdr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		images.os.type = image_get_type(os_hdr);
 		images.os.comp = image_get_comp(os_hdr);
@@ -238,6 +239,7 @@
 		images.os.end = image_get_image_end(os_hdr);
 		images.os.load = image_get_load(os_hdr);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		if (fit_image_get_type(images.fit_hdr_os,
@@ -847,6 +849,7 @@
 	return 0;
 }
 
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 /**
  * image_get_kernel - verify legacy format kernel image
  * @img_addr: in RAM address of the legacy format image to be verified
@@ -897,6 +900,7 @@
 	}
 	return hdr;
 }
+#endif
 
 /**
  * boot_get_kernel - find kernel image
@@ -914,7 +918,9 @@
 		char * const argv[], bootm_headers_t *images, ulong *os_data,
 		ulong *os_len)
 {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	image_header_t	*hdr;
+#endif
 	ulong		img_addr;
 	const void *buf;
 #if defined(CONFIG_FIT)
@@ -952,6 +958,7 @@
 	*os_data = *os_len = 0;
 	buf = map_sysmem(img_addr, 0);
 	switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		printf("## Booting kernel from Legacy Image at %08lx ...\n",
 				img_addr);
@@ -994,6 +1001,7 @@
 		images->legacy_hdr_valid = 1;
 		bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		os_noffset = fit_image_load(images, FIT_KERNEL_PROP,
@@ -1131,6 +1139,7 @@
 	printf("\n## Checking Image at %08lx ...\n", addr);
 
 	switch (genimg_get_format(hdr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		puts("   Legacy image found\n");
 		if (!image_check_magic(hdr)) {
@@ -1152,6 +1161,7 @@
 		}
 		puts("OK\n");
 		return 0;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		puts("   FIT image found\n");
@@ -1211,6 +1221,7 @@
 				goto next_sector;
 
 			switch (genimg_get_format(hdr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 			case IMAGE_FORMAT_LEGACY:
 				if (!image_check_hcrc(hdr))
 					goto next_sector;
@@ -1225,6 +1236,7 @@
 					puts("OK\n");
 				}
 				break;
+#endif
 #if defined(CONFIG_FIT)
 			case IMAGE_FORMAT_FIT:
 				if (!fit_check_format(hdr))
@@ -1359,12 +1371,14 @@
 			}
 
 			switch (genimg_get_format(buffer)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 			case IMAGE_FORMAT_LEGACY:
 				header = (const image_header_t *)buffer;
 
 				len = image_get_image_size(header);
 				nand_imls_legacyimage(nand, nand_dev, off, len);
 				break;
+#endif
 #if defined(CONFIG_FIT)
 			case IMAGE_FORMAT_FIT:
 				len = fit_get_size(buffer);