aboutsummaryrefslogtreecommitdiff
path: root/drivers/fpga/zynqmppl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/fpga/zynqmppl.c')
-rw-r--r--drivers/fpga/zynqmppl.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c
index feaf34fff1..fc55d7a388 100644
--- a/drivers/fpga/zynqmppl.c
+++ b/drivers/fpga/zynqmppl.c
@@ -9,6 +9,7 @@
#include <common.h>
#include <compiler.h>
#include <cpu_func.h>
+#include <fpga.h>
#include <log.h>
#include <zynqmppl.h>
#include <zynqmp_firmware.h>
@@ -202,9 +203,12 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf,
#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
static int zynqmp_check_compatible(xilinx_desc *desc, int flags)
{
- /* If no flags set, the image is legacy */
+ /*
+ * If no flags set, the image may be legacy, but we need to
+ * signal caller this situation with specific error code.
+ */
if (!flags)
- return 0;
+ return -ENODATA;
/* For legacy bitstream images no need for other methods exist */
if ((flags & desc->flags) && flags == FPGA_LEGACY)
@@ -217,7 +221,7 @@ static int zynqmp_check_compatible(xilinx_desc *desc, int flags)
if (desc->operations->loads && (flags & desc->flags))
return 0;
- return FPGA_FAIL;
+ return -ENODEV;
}
#endif
@@ -231,8 +235,9 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize,
u32 buf_lo, buf_hi;
u32 bsize_req = (u32)bsize;
u32 ret_payload[PAYLOAD_ARG_CNT];
-
#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
+ struct fpga_secure_info info = { 0 };
+
ret = zynqmp_check_compatible(desc, flags);
if (ret) {
if (ret != -ENODATA) {
@@ -242,6 +247,21 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize,
/* If flags is not set, the image treats as legacy */
flags = FPGA_LEGACY;
}
+
+ switch (flags) {
+ case FPGA_LEGACY:
+ break; /* Handle the legacy image later in this function */
+#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
+ case FPGA_XILINX_ZYNQMP_DDRAUTH:
+ /* DDR authentication */
+ info.authflag = ZYNQMP_FPGA_AUTH_DDR;
+ info.encflag = FPGA_NO_ENC_OR_NO_AUTH;
+ return desc->operations->loads(desc, buf, bsize, &info);
+#endif
+ default:
+ printf("Unsupported bitstream type %d\n", flags);
+ return FPGA_FAIL;
+ }
#endif
if (zynqmp_firmware_version() <= PMUFW_V1_0) {
@@ -337,7 +357,10 @@ static int __maybe_unused zynqmp_str2flag(xilinx_desc *desc, const char *str)
{
if (!strncmp(str, "u-boot,fpga-legacy", 18))
return FPGA_LEGACY;
-
+#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
+ if (!strncmp(str, "u-boot,zynqmp-fpga-ddrauth", 26))
+ return FPGA_XILINX_ZYNQMP_DDRAUTH;
+#endif
return 0;
}