162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_cimenuconfig MTD_SPI_NOR
362306a36Sopenharmony_ci	tristate "SPI NOR device support"
462306a36Sopenharmony_ci	depends on MTD
562306a36Sopenharmony_ci	depends on MTD && SPI_MASTER
662306a36Sopenharmony_ci	select SPI_MEM
762306a36Sopenharmony_ci	help
862306a36Sopenharmony_ci	  This is the framework for the SPI NOR which can be used by the SPI
962306a36Sopenharmony_ci	  device drivers and the SPI NOR device driver.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciif MTD_SPI_NOR
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciconfig MTD_SPI_NOR_USE_4K_SECTORS
1462306a36Sopenharmony_ci	bool "Use small 4096 B erase sectors"
1562306a36Sopenharmony_ci	default y
1662306a36Sopenharmony_ci	help
1762306a36Sopenharmony_ci	  Many flash memories support erasing small (4096 B) sectors. Depending
1862306a36Sopenharmony_ci	  on the usage this feature may provide performance gain in comparison
1962306a36Sopenharmony_ci	  to erasing whole blocks (32/64 KiB).
2062306a36Sopenharmony_ci	  Changing a small part of the flash's contents is usually faster with
2162306a36Sopenharmony_ci	  small sectors. On the other hand erasing should be faster when using
2262306a36Sopenharmony_ci	  64 KiB block instead of 16 × 4 KiB sectors.
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci	  Please note that some tools/drivers/filesystems may not work with
2562306a36Sopenharmony_ci	  4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_cichoice
2862306a36Sopenharmony_ci	prompt "Software write protection at boot"
2962306a36Sopenharmony_ci	default MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciconfig MTD_SPI_NOR_SWP_DISABLE
3262306a36Sopenharmony_ci	bool "Disable SWP on any flashes (legacy behavior)"
3362306a36Sopenharmony_ci	help
3462306a36Sopenharmony_ci	  This option disables the software write protection on any SPI
3562306a36Sopenharmony_ci	  flashes at boot-up.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci	  Depending on the flash chip this either clears the block protection
3862306a36Sopenharmony_ci	  bits or does a "Global Unprotect" command.
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci	  Don't use this if you intent to use the software write protection
4162306a36Sopenharmony_ci	  of your SPI flash. This is only to keep backwards compatibility.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciconfig MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE
4462306a36Sopenharmony_ci	bool "Disable SWP on flashes w/ volatile protection bits"
4562306a36Sopenharmony_ci	help
4662306a36Sopenharmony_ci	  Some SPI flashes have volatile block protection bits, ie. after a
4762306a36Sopenharmony_ci	  power-up or a reset the flash is software write protected by
4862306a36Sopenharmony_ci	  default.
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci	  This option disables the software write protection for these kind
5162306a36Sopenharmony_ci	  of flashes while keeping it enabled for any other SPI flashes
5262306a36Sopenharmony_ci	  which have non-volatile write protection bits.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci	  If the software write protection will be disabled depending on
5562306a36Sopenharmony_ci	  the flash either the block protection bits are cleared or a
5662306a36Sopenharmony_ci	  "Global Unprotect" command is issued.
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci	  If you are unsure, select this option.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciconfig MTD_SPI_NOR_SWP_KEEP
6162306a36Sopenharmony_ci	bool "Keep software write protection as is"
6262306a36Sopenharmony_ci	help
6362306a36Sopenharmony_ci	  If you select this option the software write protection of any
6462306a36Sopenharmony_ci	  SPI flashes will not be changed. If your flash is software write
6562306a36Sopenharmony_ci	  protected or will be automatically software write protected after
6662306a36Sopenharmony_ci	  power-up you have to manually unlock it before you are able to
6762306a36Sopenharmony_ci	  write to it.
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciendchoice
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_cisource "drivers/mtd/spi-nor/controllers/Kconfig"
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciendif # MTD_SPI_NOR
74