Skip to content

Commit db28dbd

Browse files
GeorgeCGVkartben
authored andcommitted
drivers: flash: stm32 xspi: early init exit for memmap mode
Exit the init earlier when XSPI 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 9040dee commit db28dbd

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/flash/flash_stm32_xspi.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,21 @@ static int flash_stm32_xspi_init(const struct device *dev)
20192019
uint32_t prescaler = STM32_XSPI_CLOCK_PRESCALER_MIN;
20202020
int ret;
20212021

2022+
if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
2023+
LOG_ERR("clock control device not ready");
2024+
return -ENODEV;
2025+
}
2026+
2027+
#ifdef CONFIG_STM32_MEMMAP
2028+
/* If MemoryMapped then configure skip init */
2029+
if (stm32_xspi_is_memorymap(dev)) {
2030+
LOG_DBG("NOR init'd in MemMapped mode");
2031+
/* Force HAL instance in correct state */
2032+
dev_data->hxspi.State = HAL_XSPI_STATE_BUSY_MEM_MAPPED;
2033+
return 0;
2034+
}
2035+
#endif /* CONFIG_STM32_MEMMAP */
2036+
20222037
/* The SPI/DTR is not a valid config of data_mode/data_rate according to the DTS */
20232038
if ((dev_cfg->data_mode != XSPI_OCTO_MODE)
20242039
&& (dev_cfg->data_rate == XSPI_DTR_TRANSFER)) {
@@ -2034,21 +2049,6 @@ static int flash_stm32_xspi_init(const struct device *dev)
20342049
return ret;
20352050
}
20362051

2037-
if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
2038-
LOG_ERR("clock control device not ready");
2039-
return -ENODEV;
2040-
}
2041-
2042-
#ifdef CONFIG_STM32_MEMMAP
2043-
/* If MemoryMapped then configure skip init */
2044-
if (stm32_xspi_is_memorymap(dev)) {
2045-
LOG_DBG("NOR init'd in MemMapped mode\n");
2046-
/* Force HAL instance in correct state */
2047-
dev_data->hxspi.State = HAL_XSPI_STATE_BUSY_MEM_MAPPED;
2048-
return 0;
2049-
}
2050-
#endif /* CONFIG_STM32_MEMMAP */
2051-
20522052
if (dev_cfg->pclk_len > 3) {
20532053
/* Max 3 domain clock are expected */
20542054
LOG_ERR("Could not select %d XSPI domain clock", dev_cfg->pclk_len);

0 commit comments

Comments
 (0)