diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2022-07-08 07:52:50 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-07-12 07:52:09 +0200 |
commit | 09c4f3651085ed1761faf231c339e8c8e247bb0b (patch) | |
tree | 3a19d0c60529bb0f5571bcc414984408d6f8825b /drivers/spi | |
parent | e52335a81eb9750a9ecbe6030e822c4f5822326d (diff) | |
download | barebox-09c4f3651085ed1761faf231c339e8c8e247bb0b.tar.gz barebox-09c4f3651085ed1761faf231c339e8c8e247bb0b.tar.xz |
spi: stm32: fix reads for sizes bigger than SZ_64K-1
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>
Link: https://lore.barebox.org/20220708055250.1175444-3-ahmad@a3f.at
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/stm32_spi.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c index 0cb04a968c..639c4f1740 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); |