drivers: spi_nor: improve documentation and validation on flash layout size
The smallest region that can be erashed is one sector, so setting SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=2048 will fail at runtime when the flash page API is used to erase a single (or misaligned) page. Add a compile-time check that the requested layout page size is erasable. Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
parent
98a344fe21
commit
2d4d6f05e6
|
@ -29,7 +29,8 @@ config SPI_NOR_FLASH_LAYOUT_PAGE_SIZE
|
|||
When CONFIG_FLASH_PAGE_LAYOUT is used this driver will support
|
||||
that API. By default the page size corresponds to the block
|
||||
size (65536). Other options include the 32K-byte erase size
|
||||
(32768), and the sector size (4096).
|
||||
(32768), the sector size (4096), or any non-zero multiple of the
|
||||
sector size.
|
||||
|
||||
config SPI_NOR_IDLE_IN_DPD
|
||||
bool "Use Deep Power-Down mode when flash is not being accessed."
|
||||
|
|
|
@ -528,6 +528,9 @@ static int spi_nor_init(struct device *dev)
|
|||
/* instance 0 size in bytes */
|
||||
#define INST_0_BYTES (DT_INST_0_JEDEC_SPI_NOR_SIZE / 8)
|
||||
|
||||
BUILD_ASSERT_MSG(SPI_NOR_IS_SECTOR_ALIGNED(CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE),
|
||||
"SPI_NOR_FLASH_LAYOUT_PAGE_SIZE must be multiple of 4096");
|
||||
|
||||
/* instance 0 page count */
|
||||
#define LAYOUT_PAGES_COUNT (INST_0_BYTES / CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE)
|
||||
|
||||
|
|
Loading…
Reference in a new issue