11/*
2- * Copyright (c) 2024 ZAL Zentrum für Angewandte Luftfahrtforschung GmbH
3- * Copyright (c) 2024 Mario Paja
2+ * Copyright (c) 2024-2025 ZAL Zentrum für Angewandte Luftfahrtforschung GmbH
3+ * Copyright (c) 2024-2025 Mario Paja
44 *
55 * SPDX-License-Identifier: Apache-2.0
66 */
@@ -276,17 +276,23 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
276276 /* HACK: This field is used to inform driver that it is overridden */
277277 dma_cfg .linked_channel = STM32_DMA_HAL_OVERRIDE ;
278278
279- /* Because of the STREAM OFFSET, the DMA channel given here is from 1 - */
280- ret = dma_config (stream -> dma_dev , stream -> dma_channel , & dma_cfg );
279+ /* Because of the STREAM OFFSET, the DMA channel given here is from 1 - 8 */
280+ ret = dma_config (stream -> dma_dev , stream -> dma_channel + STM32_DMA_STREAM_OFFSET , & dma_cfg );
281281
282282 if (ret != 0 ) {
283283 LOG_ERR ("Failed to configure DMA channel %d" ,
284284 stream -> dma_channel + STM32_DMA_STREAM_OFFSET );
285285 return ret ;
286286 }
287287
288+ #if defined(CONFIG_SOC_SERIES_STM32H7X )
289+ hdma -> Instance = __LL_DMA_GET_STREAM_INSTANCE (stream -> reg , stream -> dma_channel );
290+ hdma -> Init .PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD ;
291+ hdma -> Init .MemDataAlignment = DMA_PDATAALIGN_HALFWORD ;
292+ hdma -> Init .Priority = DMA_PRIORITY_HIGH ;
293+ hdma -> Init .FIFOMode = DMA_FIFOMODE_DISABLE ;
294+ #else
288295 hdma -> Instance = LL_DMA_GET_CHANNEL_INSTANCE (stream -> reg , stream -> dma_channel );
289- hdma -> Init .Request = dma_cfg .dma_slot ;
290296 hdma -> Init .BlkHWRequest = DMA_BREQ_SINGLE_BURST ;
291297 hdma -> Init .SrcDataWidth = DMA_SRC_DATAWIDTH_HALFWORD ;
292298 hdma -> Init .DestDataWidth = DMA_DEST_DATAWIDTH_HALFWORD ;
@@ -295,17 +301,34 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
295301 hdma -> Init .DestBurstLength = 1 ;
296302 hdma -> Init .TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0 | DMA_DEST_ALLOCATED_PORT0 ;
297303 hdma -> Init .TransferEventMode = DMA_TCEM_BLOCK_TRANSFER ;
304+ #endif
305+
306+ hdma -> Init .Request = dma_cfg .dma_slot ;
298307 hdma -> Init .Mode = DMA_NORMAL ;
299308
300309 if (stream -> dma_cfg .channel_direction == (enum dma_channel_direction )MEMORY_TO_PERIPHERAL ) {
301310 hdma -> Init .Direction = DMA_MEMORY_TO_PERIPH ;
311+
312+ #if defined(CONFIG_SOC_SERIES_STM32H7X )
313+ hdma -> Init .PeriphInc = DMA_PINC_DISABLE ;
314+ hdma -> Init .MemInc = DMA_MINC_ENABLE ;
315+ #else
302316 hdma -> Init .SrcInc = DMA_SINC_INCREMENTED ;
303317 hdma -> Init .DestInc = DMA_DINC_FIXED ;
318+ #endif
319+
304320 __HAL_LINKDMA (hsai , hdmatx , dev_data -> hdma );
305321 } else {
306322 hdma -> Init .Direction = DMA_PERIPH_TO_MEMORY ;
323+
324+ #if defined(CONFIG_SOC_SERIES_STM32H7X )
325+ hdma -> Init .PeriphInc = DMA_PINC_ENABLE ;
326+ hdma -> Init .MemInc = DMA_MINC_DISABLE ;
327+ #else
307328 hdma -> Init .SrcInc = DMA_SINC_FIXED ;
308329 hdma -> Init .DestInc = DMA_DINC_INCREMENTED ;
330+ #endif
331+
309332 __HAL_LINKDMA (hsai , hdmarx , dev_data -> hdma );
310333 }
311334
@@ -314,10 +337,12 @@ static int i2s_stm32_sai_dma_init(const struct device *dev)
314337 return - EIO ;
315338 }
316339
340+ #ifndef CONFIG_SOC_SERIES_STM32H7X
317341 if (HAL_DMA_ConfigChannelAttributes (& dev_data -> hdma , DMA_CHANNEL_NPRIV ) != HAL_OK ) {
318342 LOG_ERR ("HAL_DMA_ConfigChannelAttributes: <Failed>" );
319343 return - EIO ;
320344 }
345+ #endif
321346
322347 return 0 ;
323348}
0 commit comments