divers: flash: flash_stm32: add flash configuration check

Add weak function to check flash configuration.
On stm32g4: single bank configuration not supported
when dual bank capable.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
This commit is contained in:
Alexandre Bourdiol 2020-12-09 11:10:04 +01:00 committed by Carles Cufí
commit 522cda3f7d
2 changed files with 26 additions and 0 deletions

View file

@ -233,3 +233,16 @@ void flash_stm32_page_layout(const struct device *dev,
*layout = stm32g4_flash_layout;
*layout_size = ARRAY_SIZE(stm32g4_flash_layout);
}
/* Override weak function */
int flash_stm32_check_configuration(void)
{
#if defined(FLASH_OPTR_DBANK)
if (READ_BIT(FLASH->OPTR, FLASH_OPTR_DBANK) == 0U) {
/* Single bank not supported when dualbank is possible */
LOG_ERR("Single bank configuration not supported");
return -ENOTSUP;
}
#endif
return 0;
}