[PATCH 0/4] spi-mem: Allow specifying the byte order in DTR mode

Tudor Ambarus
2022-02-18T15:21:16Z

There are NOR flashes (Macronix) that swap the bytes on a 16-bit boundary
when configured in DTR mode. The byte order of 16-bit words is swapped
when read or written in Double Transfer Rate (DTR) mode compared to
Single Transfer Rate (STR) mode. If one writes D0 D1 D2 D3 bytes using
1-1-1 mode, and uses 8D-8D-8D SPI mode for reading, it will read back
D1 D0 D3 D2. Swapping the bytes may introduce some endianness problems.
It can affect the boot sequence if the entire boot sequence is not handled
in either 8D-8D-8D mode or 1-1-1 mode. Fortunately there are controllers
that can swap back the bytes at runtime, fixing the endiannesses. Provide
a way for the upper layers to specify the byte order in DTR mode.

Tested with atmel-quadspi and mx66lm1g45g.

Tudor Ambarus (4):
spi: spi-mem: Allow specifying the byte order in DTR mode
mtd: spi-nor: core: Allow specifying the byte order in DTR mode
mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT
mtd: spi-nor: core: Introduce SPI_NOR_DTR_BSWAP16 no_sfdp_flag

drivers/mtd/spi-nor/core.c | 36 +++++++++++++++++++++++++++++-------
drivers/mtd/spi-nor/core.h | 6 +++++-
drivers/mtd/spi-nor/sfdp.c | 3 +++
drivers/mtd/spi-nor/sfdp.h | 1 +
include/linux/mtd/spi-nor.h | 17 +++++++++++++++++
include/linux/spi/spi-mem.h | 3 +++
6 files changed, 58 insertions(+), 8 deletions(-)

--
2.25.1