Skip to content

Commit 679a6c6

Browse files
Alain Volmatjhedberg
authored andcommitted
memc: stm32_xspi_psram: avoid XSPIM_Config if running from flash
Avoid calling the HAL_XSPIM_Config function if the app is running from flash in order to avoid locking since HAL_XSPIM_Config is once turning off each XSPI instance when performing the configuration. Signed-off-by: Alain Volmat <[email protected]>
1 parent 299e067 commit 679a6c6

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

drivers/memc/memc_stm32_xspi_psram.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ static int memc_stm32_xspi_psram_init(const struct device *dev)
217217
struct memc_stm32_xspi_psram_data *dev_data = dev->data;
218218
XSPI_HandleTypeDef *hxspi = &dev_data->hxspi;
219219
uint32_t ahb_clock_freq;
220-
XSPIM_CfgTypeDef cfg = {0};
221220
XSPI_RegularCmdTypeDef cmd = {0};
222221
XSPI_MemoryMappedTypeDef mem_mapped_cfg = {0};
223222
uint32_t prescaler = STM32_XSPI_CLOCK_PRESCALER_MIN;
@@ -295,16 +294,24 @@ static int memc_stm32_xspi_psram_init(const struct device *dev)
295294
return -EIO;
296295
}
297296

298-
if (hxspi->Instance == XSPI1) {
299-
cfg.IOPort = HAL_XSPIM_IOPORT_1;
300-
} else if (hxspi->Instance == XSPI2) {
301-
cfg.IOPort = HAL_XSPIM_IOPORT_2;
302-
}
303-
cfg.nCSOverride = HAL_XSPI_CSSEL_OVR_DISABLED;
297+
if (!IS_ENABLED(CONFIG_STM32_APP_IN_EXT_FLASH)) {
298+
/*
299+
* Do not configure the XSPIManager if running on the ext flash
300+
* since this includes stopping each XSPI instance during configuration
301+
*/
302+
XSPIM_CfgTypeDef cfg = {0};
303+
304+
if (hxspi->Instance == XSPI1) {
305+
cfg.IOPort = HAL_XSPIM_IOPORT_1;
306+
} else if (hxspi->Instance == XSPI2) {
307+
cfg.IOPort = HAL_XSPIM_IOPORT_2;
308+
}
309+
cfg.nCSOverride = HAL_XSPI_CSSEL_OVR_DISABLED;
304310

305-
if (HAL_XSPIM_Config(hxspi, &cfg, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
306-
LOG_ERR("XSPIMgr Init failed");
307-
return -EIO;
311+
if (HAL_XSPIM_Config(hxspi, &cfg, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
312+
LOG_ERR("XSPIMgr Init failed");
313+
return -EIO;
314+
}
308315
}
309316

310317
/* Configure AP memory registers */

0 commit comments

Comments
 (0)