Skip to content

Commit 84f8da1

Browse files
committed
drivers: Flash: Add SPI NAND Flash driver support
Add SPI NAND Flash driver support Signed-off-by: Daniel Zhang <danielzhang@mxic.com.cn>
1 parent 621f29e commit 84f8da1

File tree

8 files changed

+1659
-0
lines changed

8 files changed

+1659
-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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 "SPI NAND init priority"
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 "Software ECC for SPI NAND flash"
25+
help
26+
Enable this option to use software-based ECC (Error Correction Code)
27+
when accessing SPI NAND flash devices. This is useful for platforms
28+
that do not support hardware ECC, or when additional software control
29+
over ECC handling is required.
30+
31+
config SPI_NAND_ECC_STEP_SIZE
32+
int "ECC step size (bytes)"
33+
default 512
34+
depends on SPI_NAND_SOFTWARE_ECC
35+
help
36+
Specifies the ECC (Error Correction Code) step size in bytes for SPI NAND
37+
flash operations. This value determines how many bytes of data are protected
38+
by one ECC block.
39+
40+
config SPI_NAND_BCH_HEAP_SIZE
41+
int "BCH heap size (bytes)"
42+
default 51200
43+
help
44+
Specify the heap size (in bytes) reserved for BCH (Bose-Chaudhuri-Hocquenghem)
45+
error correction in SPI NAND flash operations.
46+
47+
endif # SPI_NAND

0 commit comments

Comments
 (0)