summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDhruva Gole <d-gole@ti.com>2022-11-18 17:40:01 +0530
committerAnand Gadiyar <gadiyar@ti.com>2022-11-21 09:33:41 -0600
commit1d756bbc231f931b8a0ce225713943f32688b85f (patch)
tree01925a7b0b7ebc76e26b058ebffa86a875ec2106 /drivers
parentaf66450d92848384af1c76323f12865f87b7d336 (diff)
spi: cadence_qspi: use STIG mode for small reads
Fix the issue where some flash chips like cypress S25HS256T return the value of the same register over and over in DAC mode. For example in the TI K3-AM62x Processors refer [0] Technical Reference Manual there is a layer of digital logic in front of the QSPI/OSPI Driver when used in DAC mode. This is part of the Flash Subsystem (FSS) which provides access to external Flash devices. This operates by default in a 32 bit mode causing it to always align all data to 4 bytes from a 4byte aligned address. In some flash chips like cypress for example if we try to read some regs in DAC mode then it keeps sending the value of the first register that was requested and inorder to read the next reg, we have to stop and re-initiate a new transaction. This causes wrong registers values to be read than what is desired when registers are read in DAC mode. Hence if the data.nbytes is very less then prefer STIG mode for such small reads. [0] https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf Signed-off-by: Dhruva Gole <d-gole@ti.com> Tested-by: Vaishnav Achath <vaishnav.a@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/cadence_qspi.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index a839c8d2a2..485fe40113 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -826,7 +826,13 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi,
plat->is_decoded_cs);
if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) {
- if (!op->addr.nbytes)
+ /*
+ * Performing reads in DAC mode forces to read minimum 4 bytes
+ * which is unsupported on some flash devices during register
+ * reads, prefer STIG mode for such small reads.
+ */
+ if (!op->addr.nbytes ||
+ op->data.nbytes < CQSPI_STIG_DATA_LEN_MAX)
mode = CQSPI_STIG_READ;
else
mode = CQSPI_READ;