drivers: flash: Introduce API function for flash extended operations

Besides of standard flash operations like write or erase, flash
controllers also support additional features like write protection or
readout protection. These features are not available in every flash
controller, what's more controllers can implement it in a different way.

It doesn't make sense to add a separate flash API function for every
flash controller feature, because it could be unique (supported on small
number of flash controllers) or the API won't be able to represent the
same feature on every flash controller.

Extended operation interface provides flexible way for supporting flash
controller features. Code space is divided equally into Zephyr codes
(MSb == 0) and vendor codes (MSb == 1). This way we can easily add
extended operations to the drivers without cluttering the API or
problems with API incompatibility. Extended operation can be promoted
from vendor codes to Zephyr codes if the feature is available in most
flash controllers and can be represented in the same way.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
This commit is contained in:
Patryk Duda 2022-11-10 14:38:47 +01:00 committed by Carles Cufí
commit 8a85f0e87f
3 changed files with 99 additions and 0 deletions

View file

@ -11,6 +11,12 @@ config FLASH_HAS_DRIVER_ENABLED
help
This option is enabled when any flash driver is enabled.
config FLASH_HAS_EX_OP
bool
help
This option is selected by drivers that support flash extended
operations.
config FLASH_HAS_PAGE_LAYOUT
bool
help
@ -78,6 +84,14 @@ config FLASH_PAGE_LAYOUT
help
Enables API for retrieving the layout of flash memory pages.
config FLASH_EX_OP_ENABLED
bool "API for extended flash operations"
depends on FLASH_HAS_EX_OP
default n
help
Enables flash extended operations API. It can be used to perform
non-standard operations e.g. manipulating flash protection.
config FLASH_INIT_PRIORITY
int "Flash init priority"
default KERNEL_INIT_PRIORITY_DEVICE