Skip to content

Commit d580172

Browse files
committed
drivers: Flash: Add SPI NAND Flash driver support
Add SPI NAND Flash driver support Signed-off-by: danielzhang <[email protected]>
1 parent 621f29e commit d580172

File tree

8 files changed

+1660
-0
lines changed

8 files changed

+1660
-0
lines changed

drivers/flash/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_SMARTBOND flash_smartbond.c)
6767
zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_TELINK_B91 soc_flash_b91.c)
6868
zephyr_library_sources_ifdef(CONFIG_SOC_FLASH_XMC4XXX soc_flash_xmc4xxx.c)
6969
zephyr_library_sources_ifdef(CONFIG_SPI_FLASH_AT45 spi_flash_at45.c)
70+
zephyr_library_sources_ifdef(CONFIG_SPI_NAND bch.c)
71+
zephyr_library_sources_ifdef(CONFIG_SPI_NAND spi_nand.c)
7072
zephyr_library_sources_ifdef(CONFIG_SPI_NOR spi_nor.c)
7173
# zephyr-keep-sorted-stop
7274

drivers/flash/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ source "drivers/flash/Kconfig.lpc"
181181
source "drivers/flash/Kconfig.max32"
182182
source "drivers/flash/Kconfig.mcux"
183183
source "drivers/flash/Kconfig.mspi"
184+
source "drivers/flash/Kconfig.nand"
184185
source "drivers/flash/Kconfig.nor"
185186
source "drivers/flash/Kconfig.nordic_qspi_nor"
186187
source "drivers/flash/Kconfig.npcx_fiu"

drivers/flash/Kconfig.nand

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2022-2025 Macronix International Co., Ltd.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
menuconfig SPI_NAND
5+
bool "SPI NAND Flash"
6+
default y
7+
depends on DT_HAS_JEDEC_SPI_NAND_ENABLED
8+
select FLASH_HAS_DRIVER_ENABLED
9+
select FLASH_HAS_EXPLICIT_ERASE
10+
select FLASH_HAS_PAGE_LAYOUT
11+
select SPI
12+
13+
if SPI_NAND
14+
15+
config SPI_NAND_INIT_PRIORITY
16+
int
17+
default 80
18+
help
19+
Device driver initialization priority.
20+
Device is connected to SPI bus, it has to
21+
be initialized after SPI driver.
22+
23+
config SPI_NAND_SOFTWARE_ECC
24+
bool
25+
default n
26+
help
27+
Enable this option to use software-based ECC (Error Correction Code)
28+
when accessing SPI NAND flash devices. This is useful for platforms
29+
that do not support hardware ECC, or when additional software control
30+
over ECC handling is required.
31+
32+
config SPI_NAND_ECC_STEP_SIZE
33+
int
34+
default 512
35+
depends on SPI_NAND_SOFTWARE_ECC
36+
help
37+
Specifies the ECC (Error Correction Code) step size in bytes for SPI NAND
38+
flash operations. This value determines how many bytes of data are protected
39+
by one ECC block.
40+
41+
config SPI_NAND_BCH_HEAP_SIZE
42+
int
43+
default 51200
44+
help
45+
Specify the heap size (in bytes) reserved for BCH (Bose-Chaudhuri-Hocquenghem)
46+
error correction in SPI NAND flash operations.
47+
48+
endif # SPI_NAND

0 commit comments

Comments
 (0)