Skip to content

Commit

Permalink
drivers: flash: stm32 xspi: early init exit for memmap mode
Browse files Browse the repository at this point in the history
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 <geo.cgv@gmail.com>
  • Loading branch information
GeorgeCGV committed Jan 10, 2025
1 parent 12b8ebe commit 7d21dfb
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions drivers/flash/flash_stm32_xspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,21 @@ static int flash_stm32_xspi_init(const struct device *dev)
uint32_t prescaler = STM32_XSPI_CLOCK_PRESCALER_MIN;
int ret;

if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}

#ifdef CONFIG_STM32_MEMMAP
/* If MemoryMapped then configure skip init */
if (stm32_xspi_is_memorymap(dev)) {
LOG_DBG("NOR init'd in MemMapped mode");
/* Force HAL instance in correct state */
dev_data->hxspi.State = HAL_XSPI_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 != XSPI_OCTO_MODE)
&& (dev_cfg->data_rate == XSPI_DTR_TRANSFER)) {
Expand All @@ -2034,21 +2049,6 @@ static int flash_stm32_xspi_init(const struct device *dev)
return ret;
}

if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}

#ifdef CONFIG_STM32_MEMMAP
/* If MemoryMapped then configure skip init */
if (stm32_xspi_is_memorymap(dev)) {
LOG_DBG("NOR init'd in MemMapped mode\n");
/* Force HAL instance in correct state */
dev_data->hxspi.State = HAL_XSPI_STATE_BUSY_MEM_MAPPED;
return 0;
}
#endif /* CONFIG_STM32_MEMMAP */

if (dev_cfg->pclk_len > 3) {
/* Max 3 domain clock are expected */
LOG_ERR("Could not select %d XSPI domain clock", dev_cfg->pclk_len);
Expand Down

0 comments on commit 7d21dfb

Please sign in to comment.