All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] mkimage: Report information about fpga
@ 2016-05-17 12:59 Michal Simek
  2016-05-17 12:59 ` [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm Michal Simek
  2016-05-19  3:58 ` [U-Boot] [PATCH 1/2] mkimage: Report information about fpga Simon Glass
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Simek @ 2016-05-17 12:59 UTC (permalink / raw)
  To: u-boot

Add FIT_FPGA_PROP that user can identify an optional
entry for fpga.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 common/image-fit.c                    |  4 +++
 common/image.c                        |  1 +
 doc/uImage.FIT/multi-with-fpga.its    | 67 +++++++++++++++++++++++++++++++++++
 doc/uImage.FIT/source_file_format.txt |  3 ++
 include/image.h                       |  4 ++-
 5 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 doc/uImage.FIT/multi-with-fpga.its

diff --git a/common/image-fit.c b/common/image-fit.c
index 25f8a1183d58..498ec6400425 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1483,6 +1483,10 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
 	if (uname)
 		printf("%s  FDT:          %s\n", p, uname);
 
+	uname = (char *)fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL);
+	if (uname)
+		printf("%s  FPGA:         %s\n", p, uname);
+
 	/* Print out all of the specified loadables */
 	for (loadables_index = 0;
 	     fdt_get_string_index(fit, noffset,
diff --git a/common/image.c b/common/image.c
index 9824685344bb..ec78b7eab336 100644
--- a/common/image.c
+++ b/common/image.c
@@ -160,6 +160,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_RKSPI,      "rkspi",      "Rockchip SPI Boot Image" },
 	{	IH_TYPE_ZYNQIMAGE,  "zynqimage",  "Xilinx Zynq Boot Image" },
 	{	IH_TYPE_ZYNQMPIMAGE, "zynqmpimage", "Xilinx ZynqMP Boot Image" },
+	{	IH_TYPE_FPGA,       "fpga",       "FPGA Image" },
 	{	-1,		    "",		  "",			},
 };
 
diff --git a/doc/uImage.FIT/multi-with-fpga.its b/doc/uImage.FIT/multi-with-fpga.its
new file mode 100644
index 000000000000..0cdb31fe91c4
--- /dev/null
+++ b/doc/uImage.FIT/multi-with-fpga.its
@@ -0,0 +1,67 @@
+/*
+ * U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs
+ * This example makes use of the 'loadables' field
+ */
+
+/dts-v1/;
+
+/ {
+	description = "Configuration to load fpga before Kernel";
+	#address-cells = <1>;
+
+	images {
+		fdt at 1 {
+			description = "zc706";
+			data = /incbin/("/tftpboot/devicetree.dtb");
+			type = "flat_dt";
+			arch = "arm";
+			compression = "none";
+			load = <0x10000000>;
+			hash at 1 {
+				algo = "md5";
+			};
+		};
+
+		fpga at 1 {
+			description = "FPGA";
+			data = /incbin/("/tftpboot/download.bit");
+			type = "fpga";
+			arch = "arm";
+			compression = "none";
+			load = <0x30000000>;
+			hash at 1 {
+				algo = "md5";
+			};
+		};
+
+		linux_kernel at 1 {
+			description = "Linux";
+			data = /incbin/("/tftpboot/zImage");
+			type = "kernel";
+			arch = "arm";
+			os = "linux";
+			compression = "none";
+			load = <0x8000>;
+			entry = <0x8000>;
+			hash at 1 {
+				algo = "md5";
+			};
+		};
+	};
+
+	configurations {
+		default = "config at 2";
+		config at 1 {
+			description = "Linux";
+			kernel = "linux_kernel at 1";
+			fdt = "fdt at 1";
+		};
+
+		config at 2 {
+			description = "Linux with fpga";
+			kernel = "linux_kernel at 1";
+			fdt = "fdt at 1";
+			fpga = "fpga at 1";
+		};
+	};
+};
diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
index 9c527c3e012d..3f5418045e5b 100644
--- a/doc/uImage.FIT/source_file_format.txt
+++ b/doc/uImage.FIT/source_file_format.txt
@@ -236,6 +236,7 @@ o config at 1
   |- kernel = "kernel sub-node unit name"
   |- ramdisk = "ramdisk sub-node unit name"
   |- fdt = "fdt sub-node unit-name"
+  |- fpga = "fpga sub-node unit-name"
   |- loadables = "loadables sub-node unit-name"
 
 
@@ -251,6 +252,8 @@ o config at 1
     "fdt type").
   - setup : Unit name of the corresponding setup binary (used for booting
     an x86 kernel). This contains the setup.bin file built by the kernel.
+  - fpga : Unit name of the corresponding fpga bitstream blob
+    (component image node of a "fpga type").
   - loadables : Unit name containing a list of additional binaries to be
     loaded at their given locations.  "loadables" is a comma-separated list
     of strings. U-Boot will load each binary at its given start-address.
diff --git a/include/image.h b/include/image.h
index a8488f2b392e..e2a90ca202b1 100644
--- a/include/image.h
+++ b/include/image.h
@@ -247,8 +247,9 @@ struct lmb;
 #define IH_TYPE_RKSPI		25	/* Rockchip SPI image		*/
 #define IH_TYPE_ZYNQIMAGE	26	/* Xilinx Zynq Boot Image */
 #define IH_TYPE_ZYNQMPIMAGE	27	/* Xilinx ZynqMP Boot Image */
+#define IH_TYPE_FPGA		28	/* FPGA Image */
 
-#define IH_TYPE_COUNT		28	/* Number of image types */
+#define IH_TYPE_COUNT		29	/* Number of image types */
 
 /*
  * Compression Types
@@ -810,6 +811,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
 #define FIT_LOADABLE_PROP	"loadables"
 #define FIT_DEFAULT_PROP	"default"
 #define FIT_SETUP_PROP		"setup"
+#define FIT_FPGA_PROP		"fpga"
 
 #define FIT_MAX_HASH_LEN	HASH_MAX_DIGEST_SIZE
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm
  2016-05-17 12:59 [U-Boot] [PATCH 1/2] mkimage: Report information about fpga Michal Simek
@ 2016-05-17 12:59 ` Michal Simek
  2016-05-24 15:31   ` Joe Hershberger
  2016-05-24 22:15   ` Simon Glass
  2016-05-19  3:58 ` [U-Boot] [PATCH 1/2] mkimage: Report information about fpga Simon Glass
  1 sibling, 2 replies; 5+ messages in thread
From: Michal Simek @ 2016-05-17 12:59 UTC (permalink / raw)
  To: u-boot

Add function boot_get_fpga() which find and load bitstream to
programmable logic if fpga entry is present.
Function is supported on Xilinx devices for full and partial bitstreams
in BIN and BIT format.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Tests are running on Sandbox and this support requires FPGA commands to
be enabled that's why I haven't done it.

---
 common/bootm.c      | 10 ++++++
 common/image-fit.c  |  7 ++--
 common/image.c      | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/bootstage.h |  1 +
 include/image.h     |  3 ++
 5 files changed, 111 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index c965326db416..49414142dcd2 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -246,6 +246,16 @@ int bootm_find_images(int flag, int argc, char * const argv[])
 #endif
 
 #if IMAGE_ENABLE_FIT
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
+	/* find bitstreams */
+	ret = boot_get_fpga(argc, argv, &images, IH_ARCH_DEFAULT,
+			    NULL, NULL);
+	if (ret) {
+		printf("FPGA image is corrupted or invalid\n");
+		return 1;
+	}
+#endif
+
 	/* find all of the loadables */
 	ret = boot_get_loadable(argc, argv, &images, IH_ARCH_DEFAULT,
 			       NULL, NULL);
diff --git a/common/image-fit.c b/common/image-fit.c
index 498ec6400425..ecd8177f7ae7 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -422,7 +422,8 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)
 	}
 
 	if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) ||
-	    (type == IH_TYPE_FIRMWARE) || (type == IH_TYPE_RAMDISK)) {
+	    (type == IH_TYPE_FIRMWARE) || (type == IH_TYPE_RAMDISK) ||
+	    (type == IH_TYPE_FPGA)) {
 		ret = fit_image_get_load(fit, image_noffset, &load);
 		printf("%s  Load Address: ", p);
 		if (ret)
@@ -1571,6 +1572,8 @@ static const char *fit_get_image_type_property(int type)
 		return FIT_SETUP_PROP;
 	case IH_TYPE_LOADABLE:
 		return FIT_LOADABLE_PROP;
+	case IH_TYPE_FPGA:
+		return FIT_FPGA_PROP;
 	}
 
 	return "unknown";
@@ -1685,7 +1688,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 			fit_image_check_type(fit, noffset,
 					     IH_TYPE_KERNEL_NOLOAD));
 
-	os_ok = image_type == IH_TYPE_FLATDT ||
+	os_ok = image_type == IH_TYPE_FLATDT || IH_TYPE_FPGA ||
 		fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
 		fit_image_check_os(fit, noffset, IH_OS_OPENRTOS);
 
diff --git a/common/image.c b/common/image.c
index ec78b7eab336..0be09e5c6306 100644
--- a/common/image.c
+++ b/common/image.c
@@ -32,6 +32,8 @@
 #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
 #include <libfdt.h>
 #include <fdt_support.h>
+#include <fpga.h>
+#include <xilinx.h>
 #endif
 
 #include <u-boot/md5.h>
@@ -1212,6 +1214,96 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch,
 }
 
 #if IMAGE_ENABLE_FIT
+#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
+int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
+		  uint8_t arch, const ulong *ld_start, ulong * const ld_len)
+{
+	ulong tmp_img_addr, img_data, img_len;
+	void *buf;
+	int conf_noffset;
+	int fit_img_result;
+	char *uname, *name;
+	int err;
+	int devnum = 0; /* TODO support multi fpga platforms */
+	const fpga_desc * const desc = fpga_get_desc(devnum);
+	xilinx_desc *desc_xilinx = desc->devdesc;
+
+	/* Check to see if the images struct has a FIT configuration */
+	if (!genimg_has_config(images)) {
+		debug("## FIT configuration was not specified\n");
+		return 0;
+	}
+
+	/*
+	 * Obtain the os FIT header from the images struct
+	 * copy from dataflash if needed
+	 */
+	tmp_img_addr = map_to_sysmem(images->fit_hdr_os);
+	tmp_img_addr = genimg_get_image(tmp_img_addr);
+	buf = map_sysmem(tmp_img_addr, 0);
+	/*
+	 * Check image type. For FIT images get FIT node
+	 * and attempt to locate a generic binary.
+	 */
+	switch (genimg_get_format(buf)) {
+	case IMAGE_FORMAT_FIT:
+		conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
+
+		err = fdt_get_string_index(buf, conf_noffset, FIT_FPGA_PROP, 0,
+					   (const char **)&uname);
+		if (err < 0) {
+			debug("## FPGA image is not specified\n");
+			return 0;
+		}
+		fit_img_result = fit_image_load(images,
+						tmp_img_addr,
+						(const char **)&uname,
+						&(images->fit_uname_cfg),
+						arch,
+						IH_TYPE_FPGA,
+						BOOTSTAGE_ID_FPGA_INIT,
+						FIT_LOAD_OPTIONAL_NON_ZERO,
+						&img_data, &img_len);
+
+		debug("FPGA image (%s) loaded to 0x%lx/size 0x%lx\n",
+		      uname, img_data, img_len);
+
+		if (fit_img_result < 0) {
+			/* Something went wrong! */
+			return fit_img_result;
+		}
+
+		if (img_len >= desc_xilinx->size) {
+			name = "full";
+			err = fpga_loadbitstream(devnum, (char *)img_data,
+						 img_len, BIT_FULL);
+			if (err)
+				err = fpga_load(devnum, (const void *)img_data,
+						img_len, BIT_FULL);
+		} else {
+			name = "partial";
+			err = fpga_loadbitstream(devnum, (char *)img_data,
+						 img_len, BIT_PARTIAL);
+			if (err)
+				err = fpga_load(devnum, (const void *)img_data,
+						img_len, BIT_PARTIAL);
+		}
+
+		printf("   Programming %s bitstream... ", name);
+		if (err)
+			printf("failed\n");
+		else
+			printf("OK\n");
+		break;
+	default:
+		printf("The given image format is not supported (corrupt?)\n");
+		return 1;
+	}
+
+	return 0;
+}
+#endif
+
 int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
 		uint8_t arch, const ulong *ld_start, ulong * const ld_len)
 {
diff --git a/include/bootstage.h b/include/bootstage.h
index 97653602d3dd..0880a680b9ea 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -198,6 +198,7 @@ enum bootstage_id {
 	BOOTSTAGE_ID_ACCUM_SCSI,
 	BOOTSTAGE_ID_ACCUM_SPI,
 	BOOTSTAGE_ID_ACCUM_DECOMP,
+	BOOTSTAGE_ID_FPGA_INIT,
 
 	/* a few spare for the user, from here */
 	BOOTSTAGE_ID_USER,
diff --git a/include/image.h b/include/image.h
index e2a90ca202b1..f42b2fb25b67 100644
--- a/include/image.h
+++ b/include/image.h
@@ -496,6 +496,8 @@ int genimg_get_format(const void *img_addr);
 int genimg_has_config(bootm_headers_t *images);
 ulong genimg_get_image(ulong img_addr);
 
+int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
+		uint8_t arch, const ulong *ld_start, ulong * const ld_len);
 int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 		uint8_t arch, ulong *rd_start, ulong *rd_end);
 
@@ -522,6 +524,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
  */
 int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
 		uint8_t arch, const ulong *ld_start, ulong * const ld_len);
+
 #endif /* !USE_HOSTCC */
 
 int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] mkimage: Report information about fpga
  2016-05-17 12:59 [U-Boot] [PATCH 1/2] mkimage: Report information about fpga Michal Simek
  2016-05-17 12:59 ` [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm Michal Simek
@ 2016-05-19  3:58 ` Simon Glass
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Glass @ 2016-05-19  3:58 UTC (permalink / raw)
  To: u-boot

On 17 May 2016 at 06:59, Michal Simek <michal.simek@xilinx.com> wrote:
> Add FIT_FPGA_PROP that user can identify an optional
> entry for fpga.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>  common/image-fit.c                    |  4 +++
>  common/image.c                        |  1 +
>  doc/uImage.FIT/multi-with-fpga.its    | 67 +++++++++++++++++++++++++++++++++++
>  doc/uImage.FIT/source_file_format.txt |  3 ++
>  include/image.h                       |  4 ++-
>  5 files changed, 78 insertions(+), 1 deletion(-)
>  create mode 100644 doc/uImage.FIT/multi-with-fpga.its

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm
  2016-05-17 12:59 ` [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm Michal Simek
@ 2016-05-24 15:31   ` Joe Hershberger
  2016-05-24 22:15   ` Simon Glass
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Hershberger @ 2016-05-24 15:31 UTC (permalink / raw)
  To: u-boot

On Tue, May 17, 2016 at 7:59 AM, Michal Simek <michal.simek@xilinx.com> wrote:
> Add function boot_get_fpga() which find and load bitstream to
> programmable logic if fpga entry is present.
> Function is supported on Xilinx devices for full and partial bitstreams
> in BIN and BIT format.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm
  2016-05-17 12:59 ` [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm Michal Simek
  2016-05-24 15:31   ` Joe Hershberger
@ 2016-05-24 22:15   ` Simon Glass
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Glass @ 2016-05-24 22:15 UTC (permalink / raw)
  To: u-boot

On 17 May 2016 at 06:59, Michal Simek <michal.simek@xilinx.com> wrote:
> Add function boot_get_fpga() which find and load bitstream to
> programmable logic if fpga entry is present.
> Function is supported on Xilinx devices for full and partial bitstreams
> in BIN and BIT format.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Tests are running on Sandbox and this support requires FPGA commands to
> be enabled that's why I haven't done it.
>
> ---
>  common/bootm.c      | 10 ++++++
>  common/image-fit.c  |  7 ++--
>  common/image.c      | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/bootstage.h |  1 +
>  include/image.h     |  3 ++
>  5 files changed, 111 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-24 22:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-17 12:59 [U-Boot] [PATCH 1/2] mkimage: Report information about fpga Michal Simek
2016-05-17 12:59 ` [U-Boot] [PATCH 2/2] image: Add boot_get_fpga() to load fpga with bootm Michal Simek
2016-05-24 15:31   ` Joe Hershberger
2016-05-24 22:15   ` Simon Glass
2016-05-19  3:58 ` [U-Boot] [PATCH 1/2] mkimage: Report information about fpga Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.