Skip to content

Commit 2c972d5

Browse files
talih0fabiobaltieri
authored andcommitted
drivers: flash: spi_nor: Allow page-size to be set via devicetree
In the CONFIG_SPI_NOR_SFDP_MINIMAL configuration this value is hard coded to 256 bytes. Make it configurable via devicetree. Signed-off-by: Andriy Gelman <[email protected]>
1 parent d89938f commit 2c972d5

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

drivers/flash/Kconfig.nor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ choice SPI_NOR_SFDP
2020
config SPI_NOR_SFDP_MINIMAL
2121
bool "Fixed flash configuration"
2222
help
23-
Synthesize a minimal configuration assuming 256 By page size and
23+
Synthesize a minimal configuration assuming 256 By page size (or as
24+
set by the page-size devicetree property) and
2425
standard 4 KiBy and 64 KiBy erase instructions. Requires the size and
2526
jedec-id properties in the devicetree jedec,spi-nor node.
2627

drivers/flash/spi_nor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static inline uint32_t dev_flash_size(const struct device *dev)
226226
static inline uint16_t dev_page_size(const struct device *dev)
227227
{
228228
#ifdef CONFIG_SPI_NOR_SFDP_MINIMAL
229-
return 256;
229+
return DT_INST_PROP_OR(0, page_size, 256);
230230
#else /* CONFIG_SPI_NOR_SFDP_MINIMAL */
231231
const struct spi_nor_data *data = dev->data;
232232

dts/bindings/mtd/jedec,jesd216.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,16 @@ properties:
6868
addressing is require to access the full address range, and
6969
automatically puts the device into 4-byte address mode when the device
7070
is initialized.
71+
72+
page-size:
73+
type: int
74+
description: |
75+
Number of bytes in a page from JESD216 BFP DW11
76+
77+
This property is only used in the CONFIG_SPI_NOR_SFDP_MINIMAL configuration.
78+
It is ignored if the device is configured to use SFDP data
79+
from the sfdp-bfp property (CONFIG_SPI_NOR_SFDP_DEVICETREE) or
80+
if the SFDP parameters are read from the device at
81+
runtime (CONFIG_SPI_NOR_SFDP_RUNTIME).
82+
83+
The default value is 256 bytes if the value is not specified.

0 commit comments

Comments
 (0)