Skip to content

Commit 76740ae

Browse files
FRASTMaescolar
authored andcommitted
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 <[email protected]>
1 parent 72370b2 commit 76740ae

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/flash/Kconfig.stm32

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,12 @@ config FLASH_STM32_BLOCK_REGISTERS
8484
registers improves system security, because flash content (or
8585
protection settings) can't be changed even when exploit was found.
8686

87+
config USE_MICROCHIP_QSPI_FLASH_WITH_STM32
88+
bool "Include patch for Microchip qspi flash when running with stm32"
89+
depends on DT_HAS_ST_STM32_QSPI_NOR_ENABLED
90+
help
91+
Set to use Microchip qspi flash memories which supports
92+
the Global Block Protection Unlock instruction (ULBPR - 98H),
93+
and write with SPI_NOR_CMD_PP_1_1_4 on 4 lines
94+
8795
endif # SOC_FLASH_STM32

drivers/flash/flash_stm32_qspi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,16 @@ static inline int qspi_prepare_quad_program(const struct device *dev,
187187
dev_data->qspi_write_cmd == SPI_NOR_CMD_PP_1_4_4);
188188

189189
cmd->Instruction = dev_data->qspi_write_cmd;
190+
#if defined(CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32)
191+
/* Microchip qspi-NOR flash, does not follow the standard rules */
192+
if (cmd->Instruction == SPI_NOR_CMD_PP_1_1_4) {
193+
cmd->AddressMode = QSPI_ADDRESS_4_LINES;
194+
}
195+
#else
190196
cmd->AddressMode = ((cmd->Instruction == SPI_NOR_CMD_PP_1_1_4)
191197
? QSPI_ADDRESS_1_LINE
192198
: QSPI_ADDRESS_4_LINES);
199+
#endif /* CONFIG_USE_MICROCHIP_QSPI_FLASH_WITH_STM32 */
193200
cmd->DataMode = QSPI_DATA_4_LINES;
194201
cmd->DummyCycles = 0;
195202

0 commit comments

Comments
 (0)