]> git.sur5r.net Git - u-boot/commitdiff
fpga: allow programming fpga from FIT image for all FPGA drivers
authorGoldschmidt Simon <sgoldschmidt@de.pepperl-fuchs.com>
Fri, 10 Nov 2017 14:17:41 +0000 (14:17 +0000)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 14 Dec 2017 15:09:39 +0000 (16:09 +0100)
This drops the limit that fpga is only loaded from FIT images for Xilinx.
This is done by moving the 'partial' check from 'common/image.c' to
'drivers/fpga/xilinx.c' (the only driver supporting partial images yet)
and supplies a weak default implementation in 'drivers/fpga/fpga.c'.

Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
Tested-by: Michal Simek <michal.simek@xilinx.com> (On zcu102)
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
common/bootm.c
common/image.c
drivers/fpga/fpga.c
drivers/fpga/xilinx.c
include/fpga.h

index 9493a306cd038d86b08575dba7cf97a1238933f6..adb12137c7b5ce6bbb69b39c64a7c022f7d7b3b0 100644 (file)
@@ -248,7 +248,7 @@ int bootm_find_images(int flag, int argc, char * const argv[])
 #endif
 
 #if IMAGE_ENABLE_FIT
-#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
+#if defined(CONFIG_FPGA)
        /* find bitstreams */
        ret = boot_get_fpga(argc, argv, &images, IH_ARCH_DEFAULT,
                            NULL, NULL);
index 4bcf6b3128a852ee24a4a83f8d4ee91bd70699ac..96c5f58e4c60a415abff9efe44cfdb09e3eaa565 100644 (file)
@@ -1215,7 +1215,7 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch,
 }
 
 #if IMAGE_ENABLE_FIT
-#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
+#if defined(CONFIG_FPGA)
 int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
                  uint8_t arch, const ulong *ld_start, ulong * const ld_len)
 {
@@ -1226,8 +1226,6 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
        const 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)) {
@@ -1272,7 +1270,7 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
                        return fit_img_result;
                }
 
-               if (img_len >= desc_xilinx->size) {
+               if (!fpga_is_partial_data(devnum, img_len)) {
                        name = "full";
                        err = fpga_loadbitstream(devnum, (char *)img_data,
                                                 img_len, BIT_FULL);
index e0fb1b4e783b7527bf43185cf7c053fc7c3fa0d9..6aead27f16265e5a3f66973ec5343da1a156baeb 100644 (file)
@@ -170,6 +170,15 @@ int fpga_add(fpga_type devtype, void *desc)
        return devnum;
 }
 
+/*
+ * Return 1 if the fpga data is partial.
+ * This is only required for fpga drivers that support bitstream_type.
+ */
+int __weak fpga_is_partial_data(int devnum, size_t img_len)
+{
+       return 0;
+}
+
 /*
  * Convert bitstream data and load into the fpga
  */
index 941f30010a5437dccd3737960204ec4888ea4ebb..3c057609697fe51ef51c7037b663b17f3a2ff94a 100644 (file)
@@ -24,6 +24,19 @@ static int xilinx_validate(xilinx_desc *desc, char *fn);
 
 /* ------------------------------------------------------------------------- */
 
+int fpga_is_partial_data(int devnum, size_t img_len)
+{
+       const fpga_desc * const desc = fpga_get_desc(devnum);
+       xilinx_desc *desc_xilinx = desc->devdesc;
+
+       /* Check datasize against FPGA size */
+       if (img_len >= desc_xilinx->size)
+               return 0;
+
+       /* datasize is smaller, must be partial data */
+       return 1;
+}
+
 int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
                       bitstream_type bstype)
 {
index d768fb14171af5744b799e9e81f65e03ca95e6ab..4d6da790b76a1a6a29f276cf8eaef32550c5c371 100644 (file)
@@ -54,6 +54,7 @@ void fpga_init(void);
 int fpga_add(fpga_type devtype, void *desc);
 int fpga_count(void);
 const fpga_desc *const fpga_get_desc(int devnum);
+int fpga_is_partial_data(int devnum, size_t img_len);
 int fpga_load(int devnum, const void *buf, size_t bsize,
              bitstream_type bstype);
 int fpga_fsload(int devnum, const void *buf, size_t size,