drivers: flash: qspi stm32 driver supporting requires_ulbpr

Add the support of the requires_ulbpr property when a Microchip
quad-spi flash is mounted.
Set the CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32=y flag to access
the command

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu
2024-06-19 11:27:54 +02:00
committed by Alberto Escolar
parent 72370b23ce
commit 76740ae1d1
2 changed files with 15 additions and 0 deletions

View File

@@ -84,4 +84,12 @@ config FLASH_STM32_BLOCK_REGISTERS
registers improves system security, because flash content (or
protection settings) can't be changed even when exploit was found.
config USE_MICROCHIP_QSPI_FLASH_WITH_STM32
bool "Include patch for Microchip qspi flash when running with stm32"
depends on DT_HAS_ST_STM32_QSPI_NOR_ENABLED
help
Set to use Microchip qspi flash memories which supports
the Global Block Protection Unlock instruction (ULBPR - 98H),
and write with SPI_NOR_CMD_PP_1_1_4 on 4 lines
endif # SOC_FLASH_STM32

View File

@@ -187,9 +187,16 @@ static inline int qspi_prepare_quad_program(const struct device *dev,
dev_data->qspi_write_cmd == SPI_NOR_CMD_PP_1_4_4);
cmd->Instruction = dev_data->qspi_write_cmd;
#if defined(CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32)
/* Microchip qspi-NOR flash, does not follow the standard rules */
if (cmd->Instruction == SPI_NOR_CMD_PP_1_1_4) {
cmd->AddressMode = QSPI_ADDRESS_4_LINES;
}
#else
cmd->AddressMode = ((cmd->Instruction == SPI_NOR_CMD_PP_1_1_4)
? QSPI_ADDRESS_1_LINE
: QSPI_ADDRESS_4_LINES);
#endif /* CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32 */
cmd->DataMode = QSPI_DATA_4_LINES;
cmd->DummyCycles = 0;