Commit cac8c821 authored by Tudor Ambarus's avatar Tudor Ambarus Committed by Mark Brown

spi: atmel-quadspi: Fix AHB memory accesses

Following error was seen when mounting a 16MByte ubifs:
UBIFS error (ubi0:0 pid 1893): check_lpt_type.constprop.6: invalid type (15) in LPT node type

QSPI_IFR.TFRTYP was not set correctly. When data transfer is enabled
and one wants to access the serial memory through AHB in order to:
 - read in the serial memory, but not a memory data, for example
   a JEDEC-ID, QSPI_IFR.TFRTYP must be written to '0' (both sama5d2
   and sam9x60).
 - read in the serial memory, and particularly a memory data,
   TFRTYP must be written to '1' (both sama5d2 and sam9x60).
 - write in the serial memory, but not a memory data, for example
   writing the configuration or the QSPI_SR, TFRTYP must be written
   to '2' for sama5d2 and to '0' for sam9x60.
 - write in the serial memory in particular to program a memory data,
   TFRTYP must be written to '3' for sama5d2 and to '1' for sam9x60.

Fix the setting of the QSPI_IFR.TFRTYP field.

Fixes: 2d30ac5e ("mtd: spi-nor: atmel-quadspi: Use spi-mem interface for atmel-quadspi driver")
Cc: <stable@vger.kernel.org> # v5.0+
Reported-by: default avatarTom Burkart <tom@aussec.com>
Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20201207135959.154124-2-tudor.ambarus@microchip.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3650b228
...@@ -365,10 +365,14 @@ static int atmel_qspi_set_cfg(struct atmel_qspi *aq, ...@@ -365,10 +365,14 @@ static int atmel_qspi_set_cfg(struct atmel_qspi *aq,
if (dummy_cycles) if (dummy_cycles)
ifr |= QSPI_IFR_NBDUM(dummy_cycles); ifr |= QSPI_IFR_NBDUM(dummy_cycles);
/* Set data enable */ /* Set data enable and data transfer type. */
if (op->data.nbytes) if (op->data.nbytes) {
ifr |= QSPI_IFR_DATAEN; ifr |= QSPI_IFR_DATAEN;
if (op->addr.nbytes)
ifr |= QSPI_IFR_TFRTYP_MEM;
}
/* /*
* If the QSPI controller is set in regular SPI mode, set it in * If the QSPI controller is set in regular SPI mode, set it in
* Serial Memory Mode (SMM). * Serial Memory Mode (SMM).
...@@ -393,7 +397,7 @@ static int atmel_qspi_set_cfg(struct atmel_qspi *aq, ...@@ -393,7 +397,7 @@ static int atmel_qspi_set_cfg(struct atmel_qspi *aq,
atmel_qspi_write(icr, aq, QSPI_WICR); atmel_qspi_write(icr, aq, QSPI_WICR);
atmel_qspi_write(ifr, aq, QSPI_IFR); atmel_qspi_write(ifr, aq, QSPI_IFR);
} else { } else {
if (op->data.dir == SPI_MEM_DATA_OUT) if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT)
ifr |= QSPI_IFR_SAMA5D2_WRITE_TRSFR; ifr |= QSPI_IFR_SAMA5D2_WRITE_TRSFR;
/* Set QSPI Instruction Frame registers */ /* Set QSPI Instruction Frame registers */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment