Skip to content

Commit 9040dee

Browse files
GeorgeCGVkartben
authored andcommitted
drivers: flash: stm32 ospi: early init exit for memmap mode
Exit the init earlier when OSPI is in memory map mode. Avoid unnecessary checks and prevent pin reconfiguration that might cause line spikes. Clock check beforehand is preserved. Remove '\n' from the LOG_DBG string. Signed-off-by: Georgij Cernysiov <[email protected]>
1 parent cf2d3dc commit 9040dee

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/flash/flash_stm32_ospi.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,21 @@ static int flash_stm32_ospi_init(const struct device *dev)
21032103
uint32_t prescaler = STM32_OSPI_CLOCK_PRESCALER_MIN;
21042104
int ret;
21052105

2106+
if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
2107+
LOG_ERR("clock control device not ready");
2108+
return -ENODEV;
2109+
}
2110+
2111+
#ifdef CONFIG_STM32_MEMMAP
2112+
/* If MemoryMapped then configure skip init */
2113+
if (stm32_ospi_is_memorymap(dev)) {
2114+
LOG_DBG("NOR init'd in MemMapped mode");
2115+
/* Force HAL instance in correct state */
2116+
dev_data->hospi.State = HAL_OSPI_STATE_BUSY_MEM_MAPPED;
2117+
return 0;
2118+
}
2119+
#endif /* CONFIG_STM32_MEMMAP */
2120+
21062121
/* The SPI/DTR is not a valid config of data_mode/data_rate according to the DTS */
21072122
if ((dev_cfg->data_mode != OSPI_OPI_MODE)
21082123
&& (dev_cfg->data_rate == OSPI_DTR_TRANSFER)) {
@@ -2118,21 +2133,6 @@ static int flash_stm32_ospi_init(const struct device *dev)
21182133
return ret;
21192134
}
21202135

2121-
if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
2122-
LOG_ERR("clock control device not ready");
2123-
return -ENODEV;
2124-
}
2125-
2126-
#ifdef CONFIG_STM32_MEMMAP
2127-
/* If MemoryMapped then configure skip init */
2128-
if (stm32_ospi_is_memorymap(dev)) {
2129-
LOG_DBG("NOR init'd in MemMapped mode\n");
2130-
/* Force HAL instance in correct state */
2131-
dev_data->hospi.State = HAL_OSPI_STATE_BUSY_MEM_MAPPED;
2132-
return 0;
2133-
}
2134-
#endif /* CONFIG_STM32_MEMMAP */
2135-
21362136
#if STM32_OSPI_USE_DMA
21372137
/*
21382138
* DMA configuration

0 commit comments

Comments
 (0)