
On 2/7/22 12:18, Adrian Fiergolski wrote:
From: Oleksandr Suvorov oleksandr.suvorov@foundries.io
Introduce a function which passes an fpga compatible string from FIT images to FPGA drivers. This lets the different implementations decide how to handle it.
Some code of Jorge Ramirez-Ortiz jorge@foundries.io is reused.
Signed-off-by: Oleksandr Suvorov oleksandr.suvorov@foundries.io Tested-by: Ricardo Salveti ricardo@foundries.io
common/spl/spl_fit.c | 6 ++---- drivers/fpga/fpga.c | 35 ++++++++++++++++++++++++++++------- include/fpga.h | 4 ++++ 3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 1bbf824684..0e3c2a94b6 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -588,11 +588,9 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node, compatible = fdt_getprop(ctx->fit, node, "compatible", NULL); if (!compatible) warn_deprecated("'fpga' image without 'compatible' property");
else if (strcmp(compatible, "u-boot,fpga-legacy"))
printf("Ignoring compatible = %s property\n", compatible);
ret = fpga_load(0, (void *)fpga_image->load_addr, fpga_image->size,
BIT_FULL);
- ret = fit_fpga_load(0, (void *)fpga_image->load_addr, fpga_image->size,
if (ret) { printf("%s: Cannot load the image to the FPGA\n", __func__); return ret;BIT_FULL, compatible);
diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 3b0a44b242..2266c7d83a 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -197,9 +197,9 @@ int fpga_fsload(int devnum, const void *buf, size_t size, fpga_fs_info *fpga_fsinfo) { int ret_val = FPGA_FAIL; /* assume failure */
- const fpga_desc *desc = fpga_validate(devnum, buf, size,
(char *)__func__);
const fpga_desc *desc;
desc = fpga_validate(devnum, buf, size, (char *)__func__);
this is unrelated to core change.
if (desc) { switch (desc->devtype) { case fpga_xilinx: @@ -225,10 +225,9 @@ int fpga_loads(int devnum, const void *buf, size_t size, struct fpga_secure_info *fpga_sec_info) { int ret_val = FPGA_FAIL;
- const fpga_desc *desc;
- const fpga_desc *desc = fpga_validate(devnum, buf, size,
(char *)__func__);
- desc = fpga_validate(devnum, buf, size, (char *)__func__);
the same here.
if (desc) { switch (desc->devtype) { case fpga_xilinx: @@ -249,15 +248,31 @@ int fpga_loads(int devnum, const void *buf, size_t size, } #endif
+int fit_fpga_load(int devnum, const void *buf, size_t bsize,
bitstream_type bstype, const char *compatible)
+{
- fpga_desc *desc = (fpga_desc *)fpga_validate(devnum, buf, bsize,
(char *)__func__);
This is the first fpga_validate() call
- if (!desc)
return FPGA_FAIL;
- /*
* Store the compatible string to proceed it in underlying
* functions
*/
- desc->compatible = (char *)compatible;
- return fpga_load(devnum, buf, bsize, bstype);
and inside fpga_load there is another fpga_validate call again.
+}
missing newline
/*
- Generic multiplexing code
- Generic multiplexing code:
*/ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) { int ret_val = FPGA_FAIL; /* assume failure */ const fpga_desc *desc = fpga_validate(devnum, buf, bsize, (char *)__func__);
- Each architecture must handle the mandatory FPGA DT compatible property.
unrelated.
if (desc) { switch (desc->devtype) { case fpga_xilinx: @@ -270,6 +285,9 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) break; case fpga_altera: #if defined(CONFIG_FPGA_ALTERA)
if (strncmp(desc->compatible, "u-boot,fpga-legacy", 18))
printf("Ignoring compatible = %s property\n",
#else fpga_no_sup((char *)__func__, "Altera devices");desc->compatible); ret_val = altera_load(desc->devdesc, buf, bsize);
@@ -277,6 +295,9 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) break; case fpga_lattice: #if defined(CONFIG_FPGA_LATTICE)
if (strncmp(desc->compatible, "u-boot,fpga-legacy", 18))
printf("Ignoring compatible = %s property\n",
#else fpga_no_sup((char *)__func__, "Lattice devices");desc->compatible); ret_val = lattice_load(desc->devdesc, buf, bsize);
diff --git a/include/fpga.h b/include/fpga.h index ec5144334d..2891f32106 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -35,6 +35,7 @@ typedef enum { /* typedef fpga_type */ typedef struct { /* typedef fpga_desc */ fpga_type devtype; /* switch value to select sub-functions */ void *devdesc; /* real device descriptor */
char *compatible; /* device compatible string */ } fpga_desc; /* end, typedef fpga_desc */
typedef struct { /* typedef fpga_desc */
@@ -63,6 +64,9 @@ 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); +/* the DT compatible property must be handled by the different FPGA archs */ +int fit_fpga_load(int devnum, const void *buf, size_t bsize,
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,bitstream_type bstype, const char *compatible);
M