[PATCH] firmware: zynqmp: fix loading for PMU FWv1.1

Steffen Trumtrar s.trumtrar at pengutronix.de
Fri Jun 23 04:42:56 PDT 2023


FPGA programming on ZynqMP is done by the PMU. The SoC just hands a
file to the PMU and lets it load this file to the FPGA.

The bitstream that is sent to the FPGA consists of two headers, the
optional struct bs_header and a binary-header. See comment in driver:

 (...)
 * Bitstream can be provided with an optinal header (`struct bs_header`).
 * The true bitstream starts with the binary-header composed of 21 words:
 (...)

The PMUFW v1.0 had a feature for taking the bitstream only, skipping
the header, or including the binary-header and only skipping the
optional header. This is controlled via the BIT_ONLY_BIN flag. When
the flag is set, the complete header should be skipped.

The current implementation sets the flag *and* sends the binary-header
to the PMU:

	header_length = get_header_length(mgr->buf, mgr->size);
	(...)
	body = (u32 *)&mgr->buf[header_length];

get_header_length searches for the first DUMMY_WORD, i.e. the beginning
of the binary header. Then we set body to this offset, skipping the
optional header.

The flag is always set to ZYNQMP_FPGA_BIT_ONLY_BIN, which is then obviously
incorrect. It seems like the PMUFW v1.0 was capable of still handling this
although the flag was set.

The newer PMUFW v1.1 doesn't support this and expects the flag to be
unset and getting handed binary-header+bitstream. This is the same as
the linux kernel handles bitstream loading on the ZynqMP. There the flag
is also always unset.

As this wasn't correct in the first place (although it most likely still
worked depending on PMUFW and its configuration), we won't break anything
when we just set the flag to zero as the PMUFW v1.1 expects it.

TLDR: set fpga_load flags to zero to fix firmwareloading with newer
PMUFW versions.

Signed-off-by: Steffen Trumtrar <s.trumtrar at pengutronix.de>
---
 drivers/firmware/zynqmp-fpga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
index 9c160e9098..1a9a5c1b2c 100644
--- a/drivers/firmware/zynqmp-fpga.c
+++ b/drivers/firmware/zynqmp-fpga.c
@@ -206,7 +206,7 @@ static int fpgamgr_program_finish(struct firmware_handler *fh)
 	enum xilinx_byte_order byte_order;
 	dma_addr_t addr;
 	int status = 0;
-	u8 flags = ZYNQMP_FPGA_BIT_ONLY_BIN;
+	u8 flags = 0;
 
 	if (!mgr->buf) {
 		status = -ENOBUFS;
-- 
2.41.0




More information about the barebox mailing list