// SPDX-License-Identifier: BSD-3-Clause // // Copyright(c) 2022 Intel Corporation. All rights reserved. // // Author: Liam Girdwood // Keyon Jie // Rander Wang // Janusz Jankowski // Adrian Bonislawski // Adrian Warecki #include #include #include #include #include #include #include #define DW_DMA_BUFFER_PERIOD_COUNT 0x4 #define HDA_DMA_BUFFER_PERIOD_COUNT 4 SHARED_DATA struct dma dma[] = { #if DT_NODE_HAS_STATUS(DT_NODELABEL(lpgpdma0), okay) { /* Low Power GP DMAC 0 */ .plat_data = { .dir = DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV | DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV, .caps = DMA_CAP_GP_LP, .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_ALH, .channels = 8, .period_count = DW_DMA_BUFFER_PERIOD_COUNT, }, .z_dev = DEVICE_DT_GET(DT_NODELABEL(lpgpdma0)), }, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(lpgpdma1), okay) { /* Low Power GP DMAC 1 */ .plat_data = { .dir = DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV | DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV, .caps = DMA_CAP_GP_LP, .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_ALH, .channels = 8, .period_count = DW_DMA_BUFFER_PERIOD_COUNT, }, .z_dev = DEVICE_DT_GET(DT_NODELABEL(lpgpdma1)), }, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(hda_host_in), okay) { /* Host In DMAC */ .plat_data = { .dir = DMA_DIR_LMEM_TO_HMEM, .caps = DMA_CAP_HDA, .devs = DMA_DEV_HOST, .channels = DT_PROP(DT_NODELABEL(hda_host_in), dma_channels), .period_count = HDA_DMA_BUFFER_PERIOD_COUNT, }, .z_dev = DEVICE_DT_GET(DT_NODELABEL(hda_host_in)), }, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(hda_host_out), okay) { /* Host out DMAC */ .plat_data = { .dir = DMA_DIR_HMEM_TO_LMEM, .caps = DMA_CAP_HDA, .devs = DMA_DEV_HOST, .channels = DT_PROP(DT_NODELABEL(hda_host_out), dma_channels), .period_count = HDA_DMA_BUFFER_PERIOD_COUNT, }, .z_dev = DEVICE_DT_GET(DT_NODELABEL(hda_host_out)), }, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(hda_link_in), okay) { /* Link In DMAC */ .plat_data = { .dir = DMA_DIR_DEV_TO_MEM, .caps = DMA_CAP_HDA, #ifdef CONFIG_SOC_INTEL_ACE20_LNL .devs = DMA_DEV_HDA | DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_ALH, #else .devs = DMA_DEV_HDA, #endif /* CONFIG_SOC_INTEL_ACE20_LNL */ .channels = DT_PROP(DT_NODELABEL(hda_link_in), dma_channels), .period_count = HDA_DMA_BUFFER_PERIOD_COUNT, }, .z_dev = DEVICE_DT_GET(DT_NODELABEL(hda_link_in)), }, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(hda_link_out), okay) { /* Link out DMAC */ .plat_data = { .dir = DMA_DIR_MEM_TO_DEV, .caps = DMA_CAP_HDA, #ifdef CONFIG_SOC_INTEL_ACE20_LNL .devs = DMA_DEV_HDA | DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_ALH, #else .devs = DMA_DEV_HDA, #endif /* CONFIG_SOC_INTEL_ACE20_LNL */ .channels = DT_PROP(DT_NODELABEL(hda_link_out), dma_channels), .period_count = HDA_DMA_BUFFER_PERIOD_COUNT, }, .z_dev = DEVICE_DT_GET(DT_NODELABEL(hda_link_out)), }, #endif }; const struct dma_info lib_dma = { .dma_array = dma, .num_dmas = ARRAY_SIZE(dma) }; /* Initialize all platform DMAC's */ int dmac_init(struct sof *sof) { int i; sof->dma_info = &lib_dma; /* early lock initialization for ref counting */ for (i = 0; i < sof->dma_info->num_dmas; i++) k_spinlock_init(&sof->dma_info->dma_array[i].lock); return 0; }