From 64e809afeaf1572c3246a5bca198a77d0498fd89 Mon Sep 17 00:00:00 2001
From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Date: Fri, 14 Mar 2014 16:35:38 +0530
Subject: [PATCH] fpga: Guard the LOADMK functionality with CMD_FPGA_LOADMK

Guard the LOADMK functionality with config to provide
an option to enable or disable it.
Enable it for all platforms in mainline which enable CONFIG_CMD_FPGA.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
 README                           | 4 ++++
 common/cmd_fpga.c                | 8 ++++++++
 include/configs/GEN860T.h        | 1 +
 include/configs/MVBC_P.h         | 1 +
 include/configs/MVBLM7.h         | 1 +
 include/configs/MVSMR.h          | 1 +
 include/configs/alpr.h           | 1 +
 include/configs/astro_mcf5373l.h | 1 +
 include/configs/balloon3.h       | 1 +
 include/configs/coreboot.h       | 1 +
 include/configs/grsim.h          | 1 +
 include/configs/grsim_leon2.h    | 1 +
 include/configs/iocon.h          | 1 +
 include/configs/mt_ventoux.h     | 1 +
 include/configs/omap3_mvblx.h    | 1 +
 include/configs/x600.h           | 1 +
 include/configs/zynq-common.h    | 1 +
 17 files changed, 27 insertions(+)

diff --git a/README b/README
index 5f895520e8..d362880c72 100644
--- a/README
+++ b/README
@@ -2550,6 +2550,10 @@ CBFS (Coreboot Filesystem) support
 
 		Specify the number of FPGA devices to support.
 
+		CONFIG_CMD_FPGA_LOADMK
+
+		Enable support for fpga loadmk command
+
 		CONFIG_SYS_FPGA_PROG_FEEDBACK
 
 		Enable printing of hash marks during FPGA configuration.
diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c
index 010cd24e63..68b54277ad 100644
--- a/common/cmd_fpga.c
+++ b/common/cmd_fpga.c
@@ -126,10 +126,12 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		if (!fpga_data || !data_size)
 			wrong_parms = 1;
 		break;
+#if defined(CONFIG_CMD_FPGA_LOADMK)
 	case FPGA_LOADMK:
 		if (!fpga_data)
 			wrong_parms = 1;
 		break;
+#endif
 	}
 
 	if (wrong_parms) {
@@ -153,6 +155,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		rc = fpga_loadbitstream(dev, fpga_data, data_size);
 		break;
 
+#if defined(CONFIG_CMD_FPGA_LOADMK)
 	case FPGA_LOADMK:
 		switch (genimg_get_format(fpga_data)) {
 		case IMAGE_FORMAT_LEGACY:
@@ -231,6 +234,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 			break;
 		}
 		break;
+#endif
 
 	case FPGA_DUMP:
 		rc = fpga_dump(dev, fpga_data, data_size);
@@ -257,8 +261,10 @@ static int fpga_get_op(char *opstr)
 		op = FPGA_LOADB;
 	else if (!strcmp("load", opstr))
 		op = FPGA_LOAD;
+#if defined(CONFIG_CMD_FPGA_LOADMK)
 	else if (!strcmp("loadmk", opstr))
 		op = FPGA_LOADMK;
+#endif
 	else if (!strcmp("dump", opstr))
 		op = FPGA_DUMP;
 
@@ -277,10 +283,12 @@ U_BOOT_CMD(fpga, 6, 1, do_fpga,
 	   "  load\t[dev] [address] [size]\tLoad device from memory buffer\n"
 	   "  loadb\t[dev] [address] [size]\t"
 	   "Load device from bitstream buffer (Xilinx only)\n"
+#if defined(CONFIG_CMD_FPGA_LOADMK)
 	   "  loadmk [dev] [address]\tLoad device generated with mkimage"
 #if defined(CONFIG_FIT)
 	   "\n"
 	   "\tFor loadmk operating on FIT format uImage address must include\n"
 	   "\tsubimage unit name in the form of addr:<subimg_uname>"
 #endif
+#endif
 );
diff --git a/include/configs/GEN860T.h b/include/configs/GEN860T.h
index 2822a08c0a..fd6c9763d8 100644
--- a/include/configs/GEN860T.h
+++ b/include/configs/GEN860T.h
@@ -219,6 +219,7 @@
 #define CONFIG_CMD_ELF
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_BEDBUG
 
diff --git a/include/configs/MVBC_P.h b/include/configs/MVBC_P.h
index 036396c781..1ab2b3d51a 100644
--- a/include/configs/MVBC_P.h
+++ b/include/configs/MVBC_P.h
@@ -89,6 +89,7 @@
 #define CONFIG_CMD_SDRAM
 #define CONFIG_CMD_PCI
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_I2C
 
 #undef CONFIG_WATCHDOG
diff --git a/include/configs/MVBLM7.h b/include/configs/MVBLM7.h
index 27c2fa011d..1ee4d7cc33 100644
--- a/include/configs/MVBLM7.h
+++ b/include/configs/MVBLM7.h
@@ -267,6 +267,7 @@
 #define CONFIG_CMD_PCI
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_USB
 #define CONFIG_DOS_PARTITION
 
diff --git a/include/configs/MVSMR.h b/include/configs/MVSMR.h
index ad15506fad..27f730d84b 100644
--- a/include/configs/MVSMR.h
+++ b/include/configs/MVSMR.h
@@ -74,6 +74,7 @@
 #define CONFIG_CMD_CACHE
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_NET
diff --git a/include/configs/alpr.h b/include/configs/alpr.h
index 7849b222b0..2782e559f5 100644
--- a/include/configs/alpr.h
+++ b/include/configs/alpr.h
@@ -222,6 +222,7 @@
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_I2C
 #undef CONFIG_CMD_LOADB
 #undef CONFIG_CMD_LOADS
diff --git a/include/configs/astro_mcf5373l.h b/include/configs/astro_mcf5373l.h
index d875753a66..fa64a688a4 100644
--- a/include/configs/astro_mcf5373l.h
+++ b/include/configs/astro_mcf5373l.h
@@ -88,6 +88,7 @@
 #define CONFIG_CMD_LOADS
 #define CONFIG_CMD_LOADB
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMDLINE_EDITING
 
 #define CONFIG_SYS_HUSH_PARSER
diff --git a/include/configs/balloon3.h b/include/configs/balloon3.h
index 5228ba6ef7..2f5a6609b8 100644
--- a/include/configs/balloon3.h
+++ b/include/configs/balloon3.h
@@ -54,6 +54,7 @@
 #undef	CONFIG_CMD_IMLS
 #define	CONFIG_CMD_USB
 #define	CONFIG_CMD_FPGA
+#define	CONFIG_CMD_FPGA_LOADMK
 #undef	CONFIG_LCD
 
 /*
diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h
index d1d732f211..a1a63a018d 100644
--- a/include/configs/coreboot.h
+++ b/include/configs/coreboot.h
@@ -167,6 +167,7 @@
 #define CONFIG_CMD_ECHO
 #undef CONFIG_CMD_FLASH
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_GPIO
 #define CONFIG_CMD_IMI
 #undef CONFIG_CMD_IMLS
diff --git a/include/configs/grsim.h b/include/configs/grsim.h
index 556c749f92..1e089a9bf7 100644
--- a/include/configs/grsim.h
+++ b/include/configs/grsim.h
@@ -53,6 +53,7 @@
 #define CONFIG_CMD_DIAG
 #define CONFIG_CMD_ECHO		/* echo arguments		*/
 #define CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_IRQ
 #define CONFIG_CMD_ITEST	/* Integer (and string) test	*/
 #define CONFIG_CMD_LOADB	/* loadb			*/
diff --git a/include/configs/grsim_leon2.h b/include/configs/grsim_leon2.h
index 8be98983c9..66194a8ff0 100644
--- a/include/configs/grsim_leon2.h
+++ b/include/configs/grsim_leon2.h
@@ -51,6 +51,7 @@
 #define CONFIG_CMD_DIAG
 #define CONFIG_CMD_ECHO		/* echo arguments		*/
 #define CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_IRQ
 #define CONFIG_CMD_ITEST	/* Integer (and string) test	*/
 #define CONFIG_CMD_LOADB	/* loadb			*/
diff --git a/include/configs/iocon.h b/include/configs/iocon.h
index b32095cea4..79c4736bc5 100644
--- a/include/configs/iocon.h
+++ b/include/configs/iocon.h
@@ -63,6 +63,7 @@
  */
 #define CONFIG_CMD_CACHE
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #undef CONFIG_CMD_EEPROM
 
 /*
diff --git a/include/configs/mt_ventoux.h b/include/configs/mt_ventoux.h
index e7afd07b94..01e395a49d 100644
--- a/include/configs/mt_ventoux.h
+++ b/include/configs/mt_ventoux.h
@@ -49,6 +49,7 @@
  * FPGA
  */
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_FPGA
 #define CONFIG_FPGA_XILINX
 #define CONFIG_FPGA_SPARTAN3
diff --git a/include/configs/omap3_mvblx.h b/include/configs/omap3_mvblx.h
index 8d11010f84..a3dcb152d3 100644
--- a/include/configs/omap3_mvblx.h
+++ b/include/configs/omap3_mvblx.h
@@ -127,6 +127,7 @@
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 
 #define CONFIG_SYS_I2C
 #define CONFIG_SYS_OMAP24_I2C_SPEED	100000
diff --git a/include/configs/x600.h b/include/configs/x600.h
index 7405419f0e..eae85d62c9 100644
--- a/include/configs/x600.h
+++ b/include/configs/x600.h
@@ -107,6 +107,7 @@
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_ENV
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 #define CONFIG_CMD_GPIO
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_MEMORY
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 731e69b5fd..8eea24aede 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -191,6 +191,7 @@
 #define CONFIG_FPGA_XILINX
 #define CONFIG_FPGA_ZYNQPL
 #define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
 
 /* Open Firmware flat tree */
 #define CONFIG_OF_LIBFDT
-- 
2.39.5