memc: stm32_xspi_psram: allow usage on controllers without prefetch options

On some STM32 lines, like the h7rs, there aren't XSPI prefetch options.
To support them in the PSRAM driver, conditionally exclude them from
compilation when the options are not available

Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
This commit is contained in:
Titouan Christophe 2025-04-29 11:11:50 +02:00 committed by Fabio Baltieri
commit d23b1bd4e0

View file

@ -206,7 +206,6 @@ static int memc_stm32_xspi_psram_init(const struct device *dev)
const struct memc_stm32_xspi_psram_config *dev_cfg = dev->config;
struct memc_stm32_xspi_psram_data *dev_data = dev->data;
XSPI_HandleTypeDef hxspi = dev_data->hxspi;
XSPI_TypeDef *xspi = hxspi.Instance;
uint32_t ahb_clock_freq;
XSPIM_CfgTypeDef cfg = {0};
XSPI_RegularCmdTypeDef cmd = {0};
@ -332,14 +331,21 @@ static int memc_stm32_xspi_psram_init(const struct device *dev)
}
mem_mapped_cfg.TimeOutActivation = HAL_XSPI_TIMEOUT_COUNTER_DISABLE;
#if defined(XSPI_CR_NOPREF)
mem_mapped_cfg.NoPrefetchData = HAL_XSPI_AUTOMATIC_PREFETCH_ENABLE;
#endif
#if defined(XSPI_CR_NOPREF_AXI)
mem_mapped_cfg.NoPrefetchAXI = HAL_XSPI_AXI_PREFETCH_DISABLE;
#endif
if (HAL_XSPI_MemoryMapped(&hxspi, &mem_mapped_cfg) != HAL_OK) {
return -EIO;
}
MODIFY_REG(xspi->CR, XSPI_CR_NOPREF, HAL_XSPI_AUTOMATIC_PREFETCH_DISABLE);
#if defined(XSPI_CR_NOPREF)
MODIFY_REG(hxspi.Instance->CR, XSPI_CR_NOPREF, HAL_XSPI_AUTOMATIC_PREFETCH_DISABLE);
#endif
return 0;
}