[PATCH v3 00/11] spi: airoha: driver improvements
Mikhail Kshevetskiy
mikhail.kshevetskiy at iopsys.eu
Tue Oct 28 17:28:14 CET 2025
Features:
* driver fixes & improvements
* dma support was implemented (will speedup flash reading/writing)
* spinand flash page size dirty hack required for old linux kernel was
removed, corresponding fixes were accepted to linux-next and openwrt
main
* en7523 specific workaround to prevent flash data damaging if UART_TXD
was short to GND
[General notes]
The patch series can be split on 3 parts:
* fixes + DMA acceleration (patches 1--6)
* removing of spinand flash page size dirty hack (patches 7--10)
* en7523 specific hack to avoid flash damaging
[Benchmark]
With DMA:
=> mtd read.benchmark spi-nand0 $loadaddr 0 0x8000000
Reading 134217728 byte(s) (65536 page(s)) at offset 0x00000000
Read speed: 8131kiB/s
Without DMA:
mtd read.benchmark spi-nand0 $loadaddr 0 0x8000000
Reading 134217728 byte(s) (65536 page(s)) at offset 0x00000000
Read speed: 2062kiB/s
[BIG FAT WARNING]
There is a bug within linux airoha-snfi driver (linux < 6.19). The actual
value of s?pinand page size is required for flash operations. The linux
driver can't obtain it from either the spinand request or the spinand
driver itself.
The issue was resolved with the following dirty hack:
* The bootloader (u-boot) knows the flash page settings and store it
in the SNFI registers REG_SPI_NFI_CON and REG_SPI_NFI_SECCUS_SIZE.
* This registers are not cleared during linux boot, so linux airoha-snfi
driver is able to read them during startup.
* Driver reads data from SNFI registers and uses collected flash page
settings for DMA acceleration.
* Almost anybody happy... if this specific bootloader is used.
Luckilly there is a better way to resolve an issue. It has been proven
that spinand flash page size is actually unnecessary for driver operations.
We can get all required data from dirmap requests.
The fixes for an issue was accepted to
* linux-next (will appear in linux-6.19,
see: https://lore.kernel.org/lkml/20251012121707.2296160-1-mikhail.kshevetskiy@iopsys.eu/)
* openwrt main (will appear in the next release of OpenWRT,
see: https://github.com/openwrt/openwrt/pull/20295)
This series fixes an U-Boot side of the issue. Unfortunately old or unpatched
linux < 6.19 may be unable to read/write flash properly if new bootloader was
used to boot a device.
This should not be a real issue as most users will use openwrt
Changes v2:
* use 'airoha,en7523-snand' compatible check to activate reserved mode boot hack
Changes v3:
* reorder patches, so fixes and DMA changes goes first
* write a better cover letter
Mikhail Kshevetskiy (11):
spi: airoha: remove unnecessary operation adjust_op_size
spi: airoha: add support of dual/quad wires spi modes to exec_op()
handler
spi: airoha: add dma support
spi: airoha: return an error for continuous mode dirmap creation cases
spi: airoha: support of dualio/quadio flash reading commands
spi: airoha: buffer must be 0xff-ed before writing
spi: airoha: avoid setting of page/oob sizes in REG_SPI_NFI_PAGEFMT
spi: airoha: reduce the number of modification of REG_SPI_NFI_CNFG and
REG_SPI_NFI_SECCUS_SIZE registers
spi: airoha: set custom sector size equal to flash page size
spi: airoha: avoid usage of flash specific parameters
spi: airoha: en7523: workaround flash damaging if UART_TXD was short
to GND
drivers/spi/airoha_snfi_spi.c | 688 +++++++++++++++++++++++++++-------
1 file changed, 546 insertions(+), 142 deletions(-)
--
2.51.0
More information about the U-Boot
mailing list