linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mario Kicherer <dev@kicherer.org>
To: linux-spi@vger.kernel.org
Cc: han.xu@nxp.com, broonie@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org,
	Mario Kicherer <dev@kicherer.org>
Subject: [PATCH 2/2] spi: spi-fsl-qspi: support setting sampling delay through devicetree
Date: Mon, 16 Jan 2023 12:50:50 +0100	[thread overview]
Message-ID: <20230116115050.2983406-3-dev@kicherer.org> (raw)
In-Reply-To: <20230116115050.2983406-1-dev@kicherer.org>

The internal sampling point of incoming data can be delayed by modifying
the QuadSPI_SMPR register. This patch enables setting this delay using a
device tree entry.

Signed-off-by: Mario Kicherer <dev@kicherer.org>
---
 drivers/spi/spi-fsl-qspi.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 85cc71ba624a..10faaf57db28 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -722,6 +722,7 @@ static int fsl_qspi_default_setup(struct fsl_qspi *q)
 {
 	void __iomem *base = q->iobase;
 	u32 reg, addr_offset = 0;
+	u8 sampling_delay;
 	int ret;
 
 	/* disable and unprepare clock to avoid glitch pass to controller */
@@ -756,10 +757,22 @@ static int fsl_qspi_default_setup(struct fsl_qspi *q)
 			    base + QUADSPI_FLSHCR);
 
 	reg = qspi_readl(q, base + QUADSPI_SMPR);
-	qspi_writel(q, reg & ~(QUADSPI_SMPR_FSDLY_MASK
-			| QUADSPI_SMPR_FSPHS_MASK
-			| QUADSPI_SMPR_HSENA_MASK
-			| QUADSPI_SMPR_DDRSMP_MASK), base + QUADSPI_SMPR);
+	reg = reg & ~(QUADSPI_SMPR_FSDLY_MASK
+		      | QUADSPI_SMPR_FSPHS_MASK
+		      | QUADSPI_SMPR_HSENA_MASK
+		      | QUADSPI_SMPR_DDRSMP_MASK);
+	ret = of_property_read_u8(q->dev->of_node,
+				   "fsl,qspi-sampling-delay",
+				   &sampling_delay);
+	if (!ret) {
+		if (sampling_delay <= 3)
+			reg = reg | (sampling_delay << 5);
+		else
+			dev_err(q->dev,
+				"fsl,qspi-sampling_delay %u greater than 3\n",
+				sampling_delay);
+	}
+	qspi_writel(q, reg, base + QUADSPI_SMPR);
 
 	/* We only use the buffer3 for AHB read */
 	qspi_writel(q, 0, base + QUADSPI_BUF0IND);
-- 
2.34.1


      parent reply	other threads:[~2023-01-16 12:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 11:50 [PATCH 0/2] spi: spi-fsl-qspi: support setting sampling delay through devicetree Mario Kicherer
2023-01-16 11:50 ` [PATCH 1/2] spi: dt-bindings: spi-fsl-qspi: add optional sampling-delay Mario Kicherer
2023-01-16 16:36   ` Rob Herring
2023-01-17 14:10   ` Rob Herring
2023-01-17 16:33     ` Mario Kicherer
2023-01-17 17:10       ` Krzysztof Kozlowski
2023-01-17 21:05         ` han.xu
2023-01-18  8:01           ` Michael Walle
2023-01-18  8:03             ` Krzysztof Kozlowski
2023-01-18  8:51               ` Michael Walle
2023-01-18 14:58           ` Mario Kicherer
2023-01-16 11:50 ` Mario Kicherer [this message]

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=20230116115050.2983406-3-dev@kicherer.org \
    --to=dev@kicherer.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=han.xu@nxp.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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).