* [u-boot][PATCH] spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum
@ 2020-03-20 9:35 Tudor.Ambarus at microchip.com
2020-04-03 14:56 ` Jagan Teki
0 siblings, 1 reply; 2+ messages in thread
From: Tudor.Ambarus at microchip.com @ 2020-03-20 9:35 UTC (permalink / raw)
To: u-boot
From: Tudor Ambarus <tudor.ambarus@microchip.com>
Commit: 0ebb261a0b2d ("spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum")
in linux.
When defining spi_mem_op templates we don't necessarily know the size
that will be passed when the template is actually used, and basing the
supports_op() check on op->data.nbytes to know whether there will be
data transferred for a specific operation is not possible.
Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum so that we can base
our checks on op->data.dir instead of op->data.nbytes.
This also fixes a bug identified with the atmel-quaspi driver.
The spi-nor core, when erasing sectors, fills the spi_mem_op template
using SPI_MEM_OP_NO_DATA, which initializes all the data members with
value zero. This is wrong because data.dir is treated as SPI_MEM_DATA_IN,
which translates in our driver to read accesses for erases (RICR), while
the controller expects write accesses (WICR).
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
drivers/spi/spi-mem.c | 2 +-
include/spi-mem.h | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index e900c997bd7f..ffbe20c5b1e6 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -153,7 +153,7 @@ bool spi_mem_default_supports_op(struct spi_slave *slave,
spi_check_buswidth_req(slave, op->dummy.buswidth, true))
return false;
- if (op->data.nbytes &&
+ if (op->data.dir != SPI_MEM_NO_DATA &&
spi_check_buswidth_req(slave, op->data.buswidth,
op->data.dir == SPI_MEM_DATA_OUT))
return false;
diff --git a/include/spi-mem.h b/include/spi-mem.h
index 36814efa8613..893f7bd73370 100644
--- a/include/spi-mem.h
+++ b/include/spi-mem.h
@@ -60,10 +60,12 @@
/**
* enum spi_mem_data_dir - describes the direction of a SPI memory data
* transfer from the controller perspective
+ * @SPI_MEM_NO_DATA: no data transferred
* @SPI_MEM_DATA_IN: data coming from the SPI memory
* @SPI_MEM_DATA_OUT: data sent the SPI memory
*/
enum spi_mem_data_dir {
+ SPI_MEM_NO_DATA,
SPI_MEM_DATA_IN,
SPI_MEM_DATA_OUT,
};
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [u-boot][PATCH] spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum
2020-03-20 9:35 [u-boot][PATCH] spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum Tudor.Ambarus at microchip.com
@ 2020-04-03 14:56 ` Jagan Teki
0 siblings, 0 replies; 2+ messages in thread
From: Jagan Teki @ 2020-04-03 14:56 UTC (permalink / raw)
To: u-boot
On Fri, Mar 20, 2020 at 3:05 PM <Tudor.Ambarus@microchip.com> wrote:
>
> From: Tudor Ambarus <tudor.ambarus@microchip.com>
>
> Commit: 0ebb261a0b2d ("spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum")
> in linux.
>
> When defining spi_mem_op templates we don't necessarily know the size
> that will be passed when the template is actually used, and basing the
> supports_op() check on op->data.nbytes to know whether there will be
> data transferred for a specific operation is not possible.
>
> Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum so that we can base
> our checks on op->data.dir instead of op->data.nbytes.
>
> This also fixes a bug identified with the atmel-quaspi driver.
> The spi-nor core, when erasing sectors, fills the spi_mem_op template
> using SPI_MEM_OP_NO_DATA, which initializes all the data members with
> value zero. This is wrong because data.dir is treated as SPI_MEM_DATA_IN,
> which translates in our driver to read accesses for erases (RICR), while
> the controller expects write accesses (WICR).
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-03 14:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 9:35 [u-boot][PATCH] spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum Tudor.Ambarus at microchip.com
2020-04-03 14:56 ` Jagan Teki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.