Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions drivers/flash/flash_stm32_ospi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ static int flash_stm32_ospi_init(const struct device *dev)
* the minimum information to inform the DMA slot will be in used and
* how to route callbacks.
*/
struct dma_config dma_cfg = dev_data->dma.cfg;
struct dma_config *dma_cfg = &dev_data->dma.cfg;
static DMA_HandleTypeDef hdma;

if (!device_is_ready(dev_data->dma.dev)) {
Expand All @@ -2251,22 +2251,22 @@ static int flash_stm32_ospi_init(const struct device *dev)
}

/* Proceed to the minimum Zephyr DMA driver init */
dma_cfg.user_data = &hdma;
dma_cfg->user_data = &hdma;
/* HACK: This field is used to inform driver that it is overridden */
dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE;
ret = dma_config(dev_data->dma.dev, dev_data->dma.channel, &dma_cfg);
dma_cfg->linked_channel = STM32_DMA_HAL_OVERRIDE;
ret = dma_config(dev_data->dma.dev, dev_data->dma.channel, dma_cfg);
if (ret != 0) {
LOG_ERR("Failed to configure DMA channel %d", dev_data->dma.channel);
return ret;
}

/* Proceed to the HAL DMA driver init */
if (dma_cfg.source_data_size != dma_cfg.dest_data_size) {
if (dma_cfg->source_data_size != dma_cfg->dest_data_size) {
LOG_ERR("Source and destination data sizes not aligned");
return -EINVAL;
}

int index = find_lsb_set(dma_cfg.source_data_size) - 1;
int index = find_lsb_set(dma_cfg->source_data_size) - 1;

#if CONFIG_DMA_STM32U5
/* Fill the structure for dma init */
Expand All @@ -2286,14 +2286,14 @@ static int flash_stm32_ospi_init(const struct device *dev)
hdma.Init.MemInc = DMA_MINC_ENABLE;
#endif /* CONFIG_DMA_STM32U5 */
hdma.Init.Mode = DMA_NORMAL;
hdma.Init.Priority = table_priority[dma_cfg.channel_priority];
hdma.Init.Priority = table_priority[dma_cfg->channel_priority];
hdma.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma.Instance = STM32_DMA_GET_INSTANCE(dev_data->dma.reg, dev_data->dma.channel);
#ifdef CONFIG_DMA_STM32_V1
/* TODO: Not tested in this configuration */
hdma.Init.Channel = dma_cfg.dma_slot;
hdma.Init.Channel = dma_cfg->dma_slot;
#else
hdma.Init.Request = dma_cfg.dma_slot;
hdma.Init.Request = dma_cfg->dma_slot;
#endif /* CONFIG_DMA_STM32_V1 */

/* Initialize DMA HAL */
Expand Down
18 changes: 9 additions & 9 deletions drivers/flash/flash_stm32_qspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ static int flash_stm32_qspi_init(const struct device *dev)
* the minimum information to inform the DMA slot will be in used and
* how to route callbacks.
*/
struct dma_config dma_cfg = dev_data->dma.cfg;
struct dma_config *dma_cfg = &dev_data->dma.cfg;
static DMA_HandleTypeDef hdma;

if (!device_is_ready(dev_data->dma.dev)) {
Expand All @@ -1567,34 +1567,34 @@ static int flash_stm32_qspi_init(const struct device *dev)
}

/* Proceed to the minimum Zephyr DMA driver init */
dma_cfg.user_data = &hdma;
dma_cfg->user_data = &hdma;
/* HACK: This field is used to inform driver that it is overridden */
dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE;
ret = dma_config(dev_data->dma.dev, dev_data->dma.channel, &dma_cfg);
dma_cfg->linked_channel = STM32_DMA_HAL_OVERRIDE;
ret = dma_config(dev_data->dma.dev, dev_data->dma.channel, dma_cfg);
if (ret != 0) {
return ret;
}

/* Proceed to the HAL DMA driver init */
if (dma_cfg.source_data_size != dma_cfg.dest_data_size) {
if (dma_cfg->source_data_size != dma_cfg->dest_data_size) {
LOG_ERR("Source and destination data sizes not aligned");
return -EINVAL;
}

int index = find_lsb_set(dma_cfg.source_data_size) - 1;
int index = find_lsb_set(dma_cfg->source_data_size) - 1;

hdma.Init.PeriphDataAlignment = table_p_size[index];
hdma.Init.MemDataAlignment = table_m_size[index];
hdma.Init.PeriphInc = DMA_PINC_DISABLE;
hdma.Init.MemInc = DMA_MINC_ENABLE;
hdma.Init.Mode = DMA_NORMAL;
hdma.Init.Priority = table_priority[dma_cfg.channel_priority];
hdma.Init.Priority = table_priority[dma_cfg->channel_priority];
hdma.Instance = STM32_DMA_GET_INSTANCE(dev_data->dma.reg, dev_data->dma.channel);
#ifdef CONFIG_DMA_STM32_V1
/* TODO: Not tested in this configuration */
hdma.Init.Channel = dma_cfg.dma_slot;
hdma.Init.Channel = dma_cfg->dma_slot;
#else
hdma.Init.Request = dma_cfg.dma_slot;
hdma.Init.Request = dma_cfg->dma_slot;
#endif /* CONFIG_DMA_STM32_V1 */

/* Initialize DMA HAL */
Expand Down
18 changes: 9 additions & 9 deletions drivers/i2s/i2s_stm32_sai.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
{
struct i2s_stm32_sai_data *dev_data = dev->data;
struct stream *stream = &dev_data->stream;
struct dma_config dma_cfg = dev_data->stream.dma_cfg;
struct dma_config *dma_cfg = &dev_data->stream.dma_cfg;
int ret;

SAI_HandleTypeDef *hsai = &dev_data->hsai;
Expand All @@ -291,12 +291,12 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
}

/* Proceed to the minimum Zephyr DMA driver init */
dma_cfg.user_data = hdma;
dma_cfg->user_data = hdma;

/* HACK: This field is used to inform driver that it is overridden */
dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE;
dma_cfg->linked_channel = STM32_DMA_HAL_OVERRIDE;

ret = dma_config(stream->dma_dev, stream->dma_channel, &dma_cfg);
ret = dma_config(stream->dma_dev, stream->dma_channel, dma_cfg);
if (ret != 0) {
LOG_ERR("Failed to configure DMA channel %d", stream->dma_channel);
return ret;
Expand All @@ -305,16 +305,16 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
hdma->Instance = STM32_DMA_GET_INSTANCE(stream->reg, stream->dma_channel);
hdma->Init.Mode = DMA_NORMAL;

if (dma_cfg.channel_priority >= ARRAY_SIZE(dma_priority)) {
if (dma_cfg->channel_priority >= ARRAY_SIZE(dma_priority)) {
LOG_ERR("Invalid DMA channel priority");
return -EINVAL;
}
hdma->Init.Priority = dma_priority[dma_cfg.channel_priority];
hdma->Init.Priority = dma_priority[dma_cfg->channel_priority];

#if defined(DMA_CHANNEL_1)
hdma->Init.Channel = dma_cfg.dma_slot * DMA_CHANNEL_1;
hdma->Init.Channel = dma_cfg->dma_slot * DMA_CHANNEL_1;
#else
hdma->Init.Request = dma_cfg.dma_slot;
hdma->Init.Request = dma_cfg->dma_slot;
#endif

#if defined(CONFIG_DMA_STM32U5)
Expand All @@ -336,7 +336,7 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
hdma->Init.FIFOMode = DMA_FIFOMODE_DISABLE;
#endif

if (stream->dma_cfg.channel_direction == (enum dma_channel_direction)MEMORY_TO_PERIPHERAL) {
if (dma_cfg->channel_direction == (enum dma_channel_direction)MEMORY_TO_PERIPHERAL) {
hdma->Init.Direction = DMA_MEMORY_TO_PERIPH;

#if defined(CONFIG_DMA_STM32U5)
Expand Down
8 changes: 4 additions & 4 deletions drivers/video/video_stm32_dcmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ static int stm32_dma_init(const struct device *dev)
* the minimum information to inform the DMA slot will be in used and
* how to route callbacks.
*/
struct dma_config dma_cfg = config->dma.cfg;
struct dma_config *dma_cfg = &config->dma.cfg;
static DMA_HandleTypeDef hdma;

/* Proceed to the minimum Zephyr DMA driver init */
dma_cfg.user_data = &hdma;
dma_cfg->user_data = &hdma;
/* HACK: This field is used to inform driver that it is overridden */
dma_cfg.linked_channel = STM32_DMA_HAL_OVERRIDE;
ret = dma_config(config->dma.dma_dev, config->dma.channel, &dma_cfg);
dma_cfg->linked_channel = STM32_DMA_HAL_OVERRIDE;
ret = dma_config(config->dma.dma_dev, config->dma.channel, dma_cfg);
if (ret != 0) {
LOG_ERR("Failed to configure DMA channel %d", config->dma.channel);
return ret;
Expand Down
Loading