mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH 3/3] spi: stm32: fix reads for sizes bigger than SZ_64K-1
Date: Fri,  8 Jul 2022 07:52:50 +0200	[thread overview]
Message-ID: <20220708055250.1175444-3-ahmad@a3f.at> (raw)
In-Reply-To: <20220708055250.1175444-1-ahmad@a3f.at>

stm32_spi_transfer_one() can transfer no more than SPI_CR2_TSIZE (64K - 1),
while e.g. imd tends to read more than  (64K - 1) from SPI flash:

  barebox:/ imd /dev/m25p0
  imd: error 90

Define spi_controller_mem_ops::exec_op for the SPI controller to fix
this.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/spi/stm32_spi.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c
index 0cb04a968c8a..d38207edac5f 100644
--- a/drivers/spi/stm32_spi.c
+++ b/drivers/spi/stm32_spi.c
@@ -11,6 +11,7 @@
 #include <init.h>
 #include <errno.h>
 #include <linux/reset.h>
+#include <linux/spi/spi-mem.h>
 #include <spi/spi.h>
 #include <linux/bitops.h>
 #include <clock.h>
@@ -474,6 +475,24 @@ out:
 	return ret;
 }
 
+static int stm32_spi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
+{
+	if (op->data.nbytes > SPI_CR2_TSIZE)
+		op->data.nbytes = SPI_CR2_TSIZE;
+
+	return 0;
+}
+
+static int stm32_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
+{
+	return -ENOTSUPP;
+}
+
+static const struct spi_controller_mem_ops stm32_spi_mem_ops = {
+	.adjust_op_size = stm32_spi_adjust_op_size,
+	.exec_op = stm32_spi_exec_op,
+};
+
 static int stm32_spi_get_fifo_size(struct stm32_spi_priv *priv)
 {
 	u32 count = 0;
@@ -522,6 +541,7 @@ static int stm32_spi_probe(struct device_d *dev)
 
 	master->setup = stm32_spi_setup;
 	master->transfer = stm32_spi_transfer;
+	master->mem_ops = stm32_spi_mem_ops;
 
 	master->bus_num = -1;
 	stm32_spi_dt_probe(priv);
-- 
2.34.1




  parent reply	other threads:[~2022-07-08  5:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08  5:52 [PATCH 1/3] video: stm32: stm32_ltdc: fix data enable polarity Ahmad Fatoum
2022-07-08  5:52 ` [PATCH 2/3] pinctrl: stm32: keep GPIO bank clocks enabled throughout Ahmad Fatoum
2022-07-08  5:52 ` Ahmad Fatoum [this message]
2022-07-11 10:43 ` [PATCH 1/3] video: stm32: stm32_ltdc: fix data enable polarity Sascha Hauer

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=20220708055250.1175444-3-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.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