mtd: Kconfig: add a Kconfig option to enable the support for MTD block write operations

This allows using CONFIG_IS_ENABLED(SPLMTD_WRITE) to compile out code
needed only if write support is required.
The option is added for u-boot and for SPL.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Ia48169fcd601ad51d1723923ed71d610901275e1
This commit is contained in:
Jason Zhu 2021-01-06 09:35:37 +08:00
parent 5beee4e829
commit a0166cc6be
3 changed files with 17 additions and 1 deletions

View File

@ -482,6 +482,13 @@ config MTD_BLK_U_BOOT_OFFS
Set the offset from the start of the nand,spi nand and nor flash where Set the offset from the start of the nand,spi nand and nor flash where
u-boot should be loaded from. u-boot should be loaded from.
config SPL_MTD_WRITE
bool "nand & spi nand & spi nor support for write operations in SPL"
depends on SPL_MTD_SUPPORT
default n
help
Enable write access to nand & spi nand & spi nor in SPL
config SPL_MUSB_NEW_SUPPORT config SPL_MUSB_NEW_SUPPORT
bool "Support new Mentor Graphics USB" bool "Support new Mentor Graphics USB"
help help

View File

@ -17,6 +17,13 @@ config MTD_BLK
help help
Enable mtd block model for Memory Technology Devices (MTD). Enable mtd block model for Memory Technology Devices (MTD).
config MTD_WRITE
bool "support for nand & spi nand & spi nor write operations"
depends on MTD_BLK
default y
help
Enable write access to nand & spi nand & spi nor
config MTD_NOR_FLASH config MTD_NOR_FLASH
bool "Enable parallel NOR flash support" bool "Enable parallel NOR flash support"
help help

View File

@ -486,6 +486,7 @@ ulong mtd_dread(struct udevice *udev, lbaint_t start,
} }
} }
#if CONFIG_IS_ENABLED(MTD_WRITE)
ulong mtd_dwrite(struct udevice *udev, lbaint_t start, ulong mtd_dwrite(struct udevice *udev, lbaint_t start,
lbaint_t blkcnt, const void *src) lbaint_t blkcnt, const void *src)
{ {
@ -598,6 +599,7 @@ ulong mtd_derase(struct udevice *udev, lbaint_t start,
return 0; return 0;
} }
#endif
static int mtd_blk_probe(struct udevice *udev) static int mtd_blk_probe(struct udevice *udev)
{ {
@ -648,8 +650,8 @@ static int mtd_blk_probe(struct udevice *udev)
static const struct blk_ops mtd_blk_ops = { static const struct blk_ops mtd_blk_ops = {
.read = mtd_dread, .read = mtd_dread,
#if CONFIG_IS_ENABLED(MTD_WRITE)
.write = mtd_dwrite, .write = mtd_dwrite,
#ifndef CONFIG_SPL_BUILD
.erase = mtd_derase, .erase = mtd_derase,
#endif #endif
}; };