diff --git a/drivers/flash/flash_stm32_ospi.c b/drivers/flash/flash_stm32_ospi.c index 93c31c84d2ee65e..4f5b952c8bd819a 100644 --- a/drivers/flash/flash_stm32_ospi.c +++ b/drivers/flash/flash_stm32_ospi.c @@ -2103,6 +2103,16 @@ static int flash_stm32_ospi_init(const struct device *dev) uint32_t prescaler = STM32_OSPI_CLOCK_PRESCALER_MIN; int ret; +#ifdef CONFIG_STM32_MEMMAP + /* If MemoryMapped then configure skip init */ + if (stm32_ospi_is_memorymap(dev)) { + LOG_DBG("NOR init'd in MemMapped mode\n"); + /* Force HAL instance in correct state */ + dev_data->hospi.State = HAL_OSPI_STATE_BUSY_MEM_MAPPED; + return 0; + } +#endif /* CONFIG_STM32_MEMMAP */ + /* The SPI/DTR is not a valid config of data_mode/data_rate according to the DTS */ if ((dev_cfg->data_mode != OSPI_OPI_MODE) && (dev_cfg->data_rate == OSPI_DTR_TRANSFER)) { @@ -2123,16 +2133,6 @@ static int flash_stm32_ospi_init(const struct device *dev) return -ENODEV; } -#ifdef CONFIG_STM32_MEMMAP - /* If MemoryMapped then configure skip init */ - if (stm32_ospi_is_memorymap(dev)) { - LOG_DBG("NOR init'd in MemMapped mode\n"); - /* Force HAL instance in correct state */ - dev_data->hospi.State = HAL_OSPI_STATE_BUSY_MEM_MAPPED; - return 0; - } -#endif /* CONFIG_STM32_MEMMAP */ - #if STM32_OSPI_USE_DMA /* * DMA configuration