[PATCH v11 11/13] fpga: zynqmp: add bitstream compatible checking

Oleksandr Suvorov oleksandr.suvorov at foundries.io
Tue Jul 5 21:23:18 CEST 2022


Check whether the FPGA ZynqMP driver supports the given bitstream
image type.

Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov at foundries.io>
Tested-by: Ricardo Salveti <ricardo at foundries.io>
Tested-by: Adrian Fiergolski <adrian.fiergolski at fastree3d.com>
---

(no changes since v10)

Changes in v10:
- fix grammar;

 drivers/fpga/zynqmppl.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c
index 6959b8ae97e..5e74360220e 100644
--- a/drivers/fpga/zynqmppl.c
+++ b/drivers/fpga/zynqmppl.c
@@ -199,6 +199,28 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf,
 	return 0;
 }
 
+static int zynqmp_check_compatible(xilinx_desc *desc, int flags)
+{
+	/* If no flags set, the image is legacy */
+	if (!flags)
+		return 0;
+
+	/* For legacy bitstream images no need for other methods exist */
+	if ((flags & desc->flags) && flags == FPGA_LEGACY)
+		return 0;
+
+	/*
+	 * Other images are handled in secure callback loads(). Check
+	 * callback existence besides image type support.
+	 */
+	if (CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) &&
+	    desc->operations->loads &&
+	    (flags & desc->flags))
+		return 0;
+
+	return FPGA_FAIL;
+}
+
 static int zynqmp_load(xilinx_desc *desc, const void *buf,
 		       size_t bsize, bitstream_type bstype,
 		       int flags)
@@ -213,6 +235,11 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf,
 
 	debug("%s called!\n", __func__);
 
+	if (zynqmp_check_compatible(desc, flags)) {
+		puts("Missing loads operation or unsupported bitstream type\n");
+		return FPGA_FAIL;
+	}
+
 	if (zynqmp_firmware_version() <= PMUFW_V1_0) {
 		puts("WARN: PMUFW v1.0 or less is detected\n");
 		puts("WARN: Not all bitstream formats are supported\n");
-- 
2.36.1



More information about the U-Boot mailing list