linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Koen Beel <koen.beel@b-kalm.com>
To: Moritz Fischer <mdf@kernel.org>, Xu Yilun <yilun.xu@intel.com>,
	Tom Rix <trix@redhat.com>, Michal Simek <michal.simek@amd.com>,
	linux-fpga@vger.kernel.org
Subject: [PATCH v2] fpga: zynq-fpga: fix setting pcap to max speed
Date: Fri, 24 Oct 2025 17:32:21 +0200	[thread overview]
Message-ID: <aPucBU9cUsUmbMRI@nuc> (raw)

The PCAP interface should be set to max speed if the bitstream is not
encrypted. The code comments also show this was the original intended
behavior.

According to the "Zynq 7000 SoC Technical Reference Manual (UG585)" the
reset value of the devcfg control register (XDCFG_CTRL_OFFSET) should be
0x0C006000, so CTRL_PCAP_RATE_EN_MASK (bit 25) should be 0 (= max speed)
at bootup.
However, the devcfg control register reset value seems to be different
in reality, and CTRL_PCAP_RATE_EN_MASK seems to be 1 (= reduced speed)
at bootup.

On top, I don't think it's sane for the driver to just assume a register
has a certain initial value and depend on it.

Fixes: 37784706bf9e ("fpga manager: Adding FPGA Manager support for Xilinx Zynq 7000")
Cc: stable@vger.kernel.org
Signed-off-by: Koen Beel <koen.beel@b-kalm.com>
---
 drivers/fpga/zynq-fpga.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c
index b7629a0e4813..83030ec1f376 100644
--- a/drivers/fpga/zynq-fpga.c
+++ b/drivers/fpga/zynq-fpga.c
@@ -344,19 +344,14 @@ static int zynq_fpga_ops_write_init(struct fpga_manager *mgr,
 
 	/* set configuration register with following options:
 	 * - enable PCAP interface
-	 * - set throughput for maximum speed (if bistream not encrypted)
+	 * - set throughput for maximum speed (if bitstream not encrypted)
 	 * - set CPU in user mode
 	 */
 	ctrl = zynq_fpga_read(priv, CTRL_OFFSET);
-	if (info->flags & FPGA_MGR_ENCRYPTED_BITSTREAM)
-		zynq_fpga_write(priv, CTRL_OFFSET,
-				(CTRL_PCAP_PR_MASK | CTRL_PCAP_MODE_MASK
-				 | CTRL_PCAP_RATE_EN_MASK | ctrl));
-	else
-		zynq_fpga_write(priv, CTRL_OFFSET,
-				(CTRL_PCAP_PR_MASK | CTRL_PCAP_MODE_MASK
-				 | ctrl));
-
+	ctrl |= CTRL_PCAP_PR_MASK | CTRL_PCAP_MODE_MASK;
+	FIELD_MODIFY(CTRL_PCAP_RATE_EN_MASK, &ctrl,
+		     (info->flags & FPGA_MGR_ENCRYPTED_BITSTREAM) ? 1 : 0);
+	zynq_fpga_write(priv, CTRL_OFFSET, ctrl);
 
 	/* We expect that the command queue is empty right now. */
 	status = zynq_fpga_read(priv, STATUS_OFFSET);
-- 
2.51.0






             reply	other threads:[~2025-10-24 15:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 15:32 Koen Beel [this message]
2025-10-27  2:51 ` [PATCH v2] fpga: zynq-fpga: fix setting pcap to max speed Xu Yilun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aPucBU9cUsUmbMRI@nuc \
    --to=koen.beel@b-kalm.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=michal.simek@amd.com \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).