summaryrefslogtreecommitdiff
path: root/include/linux/mtd/spinand.h
AgeCommit message (Collapse)Author
2025-11-18mtd: spinand: add support for FudanMicro FM25S01ATianling Shen
Add support for FudanMicro FM25S01A SPI NAND. This driver is ported from linux v6.18 and tested on a MT7981 board. Link: https://lore.kernel.org/linux-mtd/[email protected]/ Reviewed-by: Mikhail Kshevetskiy <[email protected]> Signed-off-by: Tianling Shen <[email protected]>
2025-10-05mtd: spinand: Sync core code and device support with Linux 6.17-rc1Mikhail Kshevetskiy
This makes the U-Boot SPI NAND driver almost the same as in Linux 6.17-rc1. The only major differences are: * support of ECC engines. The Linux driver supports different ECC engines while U-Boot uses on-die ECC only. * per operation maximum SPI bus frequency Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Add a ->configure_chip() hookMiquel Raynal
There is already a manufacturer hook, which is manufacturer specific but not chip specific. We no longer have access to the actual NAND identity at this stage so let's add a per-chip configuration hook to align the chip configuration (if any) with the core's setting. This is a port of linux commit da55809ebb45 ("mtd: spinand: Add a ->configure_chip() hook") Signed-off-by: Miquel Raynal <[email protected]> Signed-off-by: Mikhail Kshevetskiy <[email protected]> # U-Boot port Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: add OTP supportMikhail Kshevetskiy
The code was ported from linux-6.15 based on a linux commit c06b1f753bea (mtd: spinand: add OTP support) created by Martin Kurbanov <[email protected]> Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Add read retry supportCheng Ming Lin
When the host ECC fails to correct the data error of NAND device, there's a special read for data recovery method which can be setup by the host for the next read. There are several retry levels that can be attempted until the lost data is recovered or definitely assumed lost. This is the port of linux commit f2cb43c98010 (mtd: spinand: Add read retry support) Signed-off-by: Cheng Ming Lin <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Signed-off-by: Mikhail Kshevetskiy <[email protected]> # U-Boot port Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: add support of continuous reading modeMikhail Kshevetskiy
The code was ported from linux-6.12. The original continuous reading support was implemented by Miquel Raynal <[email protected]> in linux commit 631cfdd0520d (mtd: spi-nand: Add continuous read support). Here is an original patch description: -------------------------------------- A regular page read consist in: - Asking one page of content from the NAND array to be loaded in the chip's SRAM, - Waiting for the operation to be done, - Retrieving the data (I/O phase) from the chip's SRAM. When reading several sequential pages, the above operation is repeated over and over. There is however a way to optimize these accesses, by enabling continuous reads. The feature requires the NAND chip to have a second internal SRAM area plus a bit of additional internal logic to trigger another internal transfer between the NAND array and the second SRAM area while the I/O phase is ongoing. Once the first I/O phase is done, the host can continue reading more data, continuously, as the chip will automatically switch to the second SRAM content (which has already been loaded) and in turns trigger the next load into the first SRAM area again. From an instruction perspective, the command op-codes are different, but the same cycles are required. The only difference is that after a continuous read (which is stopped by a CS deassert), the host must observe a delay of tRST. However, because there is no guarantee in Linux regarding the actual state of the CS pin after a transfer (in order to speed-up the next transfer if targeting the same device), it was necessary to manually end the continuous read with a configuration register write operation. Continuous reads have two main drawbacks: * They only work on full pages (column address ignored) * Only the main data area is pulled, out-of-band bytes are not accessible. Said otherwise, the feature can only be useful with on-die ECC engines. Performance wise, measures have been performed on a Zynq platform using Macronix SPI-NAND controller with a Macronix chip (based on the flash_speed tool modified for testing sequential reads): - 1-1-1 mode: performances improved from +3% (2-pages) up to +10% after a dozen pages. - 1-1-4 mode: performances improved from +15% (2-pages) up to +40% after a dozen pages. This series is based on a previous work from Macronix engineer Jaime Liao. -------------------------------------- Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Introduce a way to avoid raw accessTakahiro Kuwano
SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed. Introduce SPINAND_NO_RAW_ACCESS flag to advertise the device does not support raw access. In such devices, the on-die ECC engine ops returns error to I/O request in raw mode. Checking and marking BBM need to be cared as special case, by adding fallback mechanism that tries read/write OOB with ECC enabled. This is a port of linux commit 6d9d6ab3a82a (mtd: spinand: Introduce a way to avoid raw access) Signed-off-by: Takahiro Kuwano <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Signed-off-by: Mikhail Kshevetskiy <[email protected]> # U-Boot port Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Add support for setting plane select bitsCheng Ming Lin
Add two flags for inserting the Plane Select bit into the column address during the write_to_cache and the read_from_cache operation. Add the SPINAND_HAS_PROG_PLANE_SELECT_BIT flag for serial NAND flash that require inserting the Plane Select bit into the column address during the write_to_cache operation. Add the SPINAND_HAS_READ_PLANE_SELECT_BIT flag for serial NAND flash that require inserting the Plane Select bit into the column address during the read_from_cache operation. This is a port of linux commit ca229bdbef29 (mtd: spinand: Add support for setting plane select bits) Signed-off-by: Cheng Ming Lin <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected] Signed-off-by: Mikhail Kshevetskiy <[email protected]> # U-Boot port Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Sync core code and device support with Linux 6.10Mikhail Kshevetskiy
This makes the U-Boot SPI NAND driver almost the same as in Linux 6.10. The only major difference is support of ECC engines. The Linux driver supports different ECC engines while U-Boot uses on-die ECC only. Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Extend spinand_wait() to match Linux kernel implementationMikhail Kshevetskiy
This aligns spinand_wait() with the linux kernel. Instead of calling into spi_mem_poll_status() which is not implemented in U-Boot, we code the polling logic and make sure that schedule() is called periodically. Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-10-05mtd: spinand: Use the spi-mem dirmap APIMikhail Kshevetskiy
Make use of the spi-mem direct mapping API to let advanced controllers optimize read/write operations when they support direct mapping. Based on a linux commit 981d1aa0697c ("mtd: spinand: Use the spi-mem dirmap API") created by Boris Brezillon <[email protected]> with additional fixes taken from Linux 6.10. Signed-off-by: Mikhail Kshevetskiy <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2025-04-16spi: drop unneeded spi.h header include from spinand.hChristian Marangi
Drop unneeded spi.h header include from spinand.h, nothing included by spi.h is actually used in this header and .c should correctly included spi.h if actually needed. Replace spi.h with linux/bitops.h as this is what is actually required for spinand.h Signed-off-by: Christian Marangi <[email protected]>
2024-04-14mtd: spinand: Add support for XTX SPINANDBruce Suen
Add support for XTX XT26G0xA and XT26xxxD. The driver is ported from linux-6.7.1. This driver is tested on Banana BPI-R3 with XT26G01A and XT26G12D. Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Bruce Suen <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Signed-off-by: Dario Binacchi <[email protected]>
2023-12-18Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi ↵Tom Rini
into next - spi_nor_read_sfdp_dma_unsafe (Vaishnav) - w25q01/02 (Jim)
2023-12-14mtd: spinand: add support for ESMT F50x1G41LBIgor Prusov
Adaptation of Linux commit d74c36480a67 This patch adds support for ESMT F50L1G41LB and F50D1G41LB. It seems that ESMT likes to use random JEDEC ID from other vendors. Their 1G chips uses 0xc8 from GigaDevice and 2G/4G chips uses 0x2c from Micron. For this reason, the ESMT entry is named esmt_c8 with explicit JEDEC ID in variable name. Datasheets: https://www.esmt.com.tw/upload/pdf/ESMT/datasheets/F50L1G41LB(2M).pdf https://www.esmt.com.tw/upload/pdf/ESMT/datasheets/F50D1G41LB(2M).pdf Signed-off-by: Igor Prusov <[email protected]> Signed-off-by: Chuanhong Guo <[email protected]> Signed-off-by: Martin Kurbanov <[email protected]> Signed-off-by: Dmitry Rokosov <[email protected]> Tested-by: Martin Kurbanov <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Reviewed-by: Jagan Teki <[email protected]>
2023-11-07include: Drop <common.h> from include listsTom Rini
At this point, we don't need to have <common.h> be included because of properties in the header itself, it only includes other common header files. We've also audited the code enough at this point that we can drop <common.h> from being included in headers and rely on code to have the correct inclusions themselves, or at least <common.h>. Signed-off-by: Tom Rini <[email protected]>
2023-10-13mtd/spinand: sync supported devices with linux-5.15.43Mikhail Kshevetskiy
This adds more supported spinand devices from the Linux kernel implementation. This does not include the latest kernel implementation as this would require a substantial amount of extra work due to the missing ECC engine abstraction layer in U-Boot. Signed-off-by: Mikhail Kshevetskiy <[email protected]> Signed-off-by: Frieder Schrempf <[email protected]> (commit message) Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Dario Binacchi <[email protected]>
2023-10-13mtd/spinand: rework detect procedure for different READ_ID operationMikhail Kshevetskiy
Currently there are 3 different variants of read_id implementation: 1. opcode only. Found in GD5FxGQ4xF. 2. opcode + 1 addr byte. Found in GD5GxGQ4xA/E 3. opcode + 1 dummy byte. Found in other currently supported chips. Original implementation was for variant 1 and let detect function of chips with variant 2 and 3 to ignore the first byte. This isn't robust: 1. For chips of variant 2, if SPI master doesn't keep MOSI low during read, chip will get a random id offset, and the entire id buffer will shift by that offset, causing detect failure. 2. For chips of variant 1, if it happens to get a devid that equals to manufacture id of variant 2 or 3 chips, it'll get incorrectly detected. This patch reworks detect procedure to address problems above. New logic do detection for all variants separatedly, in 1-2-3 order. Since all current detect methods do exactly the same id matching procedure, unify them into core.c and remove detect method from manufacture_ops. This is a rework of Chuanhong Guo <[email protected]> patch submitted to linux kernel Signed-off-by: Mikhail Kshevetskiy <[email protected]> Signed-off-by: Frieder Schrempf <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Dario Binacchi <[email protected]>
2021-01-05spi: Tidy up get/set of device nodeSimon Glass
This code is a bit odd in that it only reads and updates the livetree version of the device ofnode. This means it won't work with flattree. Update the code to work as it was presumably intended. Signed-off-by: Simon Glass <[email protected]>
2020-07-20mtd: spinand: micron: identify SPI NAND device with Continuous Read modeShivamurthy Shastri
Add SPINAND_HAS_CR_FEAT_BIT flag to identify the SPI NAND device with the Continuous Read mode. Some of the Micron SPI NAND devices have the "Continuous Read" feature enabled by default, which does not fit the subsystem needs. In this mode, the READ CACHE command doesn't require the starting column address. The device always output the data starting from the first column of the cache register, and once the end of the cache register reached, the data output continues through the next page. With the continuous read mode, it is possible to read out the entire block using a single READ command, and once the end of the block reached, the output pins become High-Z state. However, during this mode the read command doesn't output the OOB area. Hence, we disable the feature at probe time. Signed-off-by: Shivamurthy Shastri <[email protected]> Acked-by: Jagan Teki <[email protected]>
2020-04-29mtd: spi-nand: Import Toshiba SPI-NAND supportRobert Marko
Linux has good support for Toshiba SPI-NAND, so lets import it. Signed-off-by: Robert Marko <[email protected]> Tested-by: Luka Kovacic <[email protected]> Cc: Luka Perkov <[email protected]> Reviewed-by: Jagan Teki <[email protected]>
2018-10-04mtd: nand: spi: Add Gigadevice SPI NAND supportStefan Roese
This patch adds support for Gigadevices SPI NAND device to the new SPI NAND infrastructure in U-Boot. Currently only the 128MiB GD5F1GQ4UC device is supported. Signed-off-by: Stefan Roese <[email protected]> Cc: Miquel Raynal <[email protected]> Cc: Boris Brezillon <[email protected]> Cc: Jagan Teki <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Acked-by: Jagan Teki <[email protected]>
2018-09-20mtd: spinand: Add initial support for the MX35LF1GE4AB chipBoris Brezillon
Add minimal support for the MX35LF1GE4AB SPI NAND chip. Signed-off-by: Boris Brezillon <[email protected]> Acked-by: Jagan Teki <[email protected]>
2018-09-20mtd: spinand: Add initial support for Winbond W25M02GVFrieder Schrempf
Add support for the W25M02GV chip. Signed-off-by: Frieder Schrempf <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Acked-by: Jagan Teki <[email protected]>
2018-09-20mtd: spinand: Add initial support for Micron MT29F2G01ABAGDPeter Pan
Add a basic driver for Micron SPI NANDs. Only one device is supported right now, but the driver will be extended to support more devices afterwards. Signed-off-by: Peter Pan <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Acked-by: Jagan Teki <[email protected]>
2018-09-20mtd: nand: Add core infrastructure to support SPI NANDsPeter Pan
Add a SPI NAND framework based on the generic NAND framework and the spi-mem infrastructure. In its current state, this framework supports the following features: - single/dual/quad IO modes - on-die ECC Signed-off-by: Peter Pan <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Acked-by: Jagan Teki <[email protected]>