Skip to content

Commit d403fb6

Browse files
DhruvaG2000broonie
authored andcommitted
spi: cadence-quadspi: 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 Drive when used in DAC mode. This is part of the Flash Subsystem (FSS) which provides access to external Flash devices. The FSS0_0_SYSCONFIG Register (Offset = 4h) has a BIT Field for OSPI_32B_DISABLE_MODE which has a Reset value = 0. This means, OSPI 32bit mode enabled by default. Thus, by default controller operates in 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 register 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a8674ae commit d403fb6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,13 @@ static int cqspi_mem_process(struct spi_mem *mem, const struct spi_mem_op *op)
13591359
cqspi_configure(f_pdata, mem->spi->max_speed_hz);
13601360

13611361
if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) {
1362-
if (!op->addr.nbytes)
1362+
/*
1363+
* Performing reads in DAC mode forces to read minimum 4 bytes
1364+
* which is unsupported on some flash devices during register
1365+
* reads, prefer STIG mode for such small reads.
1366+
*/
1367+
if (!op->addr.nbytes ||
1368+
op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX)
13631369
return cqspi_command_read(f_pdata, op);
13641370

13651371
return cqspi_read(f_pdata, op);

0 commit comments

Comments
 (0)