Skip to content

Commit dc9eb6c

Browse files
committed
dai: acp_7_x: add SDW DMA and DAI support for ACP_7_X
Add ACP_7_X SDW DMA channel support in zephyr/lib/dma.c for native Zephyr DMA operations. Update dai.c to set dai_index from dd->dai->index for AMD SDW DAI, add ACP_7_X SDW instance handling with per-instance pin index array, and free DAI-specific data on DMA release for AMD. Signed-off-by: Sneha Voona <sneha.voona@amd.com>
1 parent 318fba6 commit dc9eb6c

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/ipc/ipc3/dai.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);
3131

32+
#define DAI_INDEX_INVALID 0xFFFF
33+
3234
void dai_set_link_hda_config(uint16_t *link_config,
3335
struct ipc_config_dai *common_config,
3436
const void *spec_config)
@@ -93,7 +95,10 @@ int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void
9395
break;
9496
case SOF_DAI_AMD_HS:
9597
case SOF_DAI_AMD_HS_VIRTUAL:
96-
case SOF_DAI_AMD_SDW:
98+
case SOF_DAI_AMD_SDW: {
99+
struct dai_config *params = (struct dai_config *)dd->dai->dev->config;
100+
101+
params->dai_index = dd->dai->index;
97102
channel = dai_get_handshake(dd->dai, dai->direction,
98103
dd->stream_id);
99104
#if defined(CONFIG_SOC_ACP_7_0)
@@ -102,6 +107,7 @@ int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void
102107
}
103108
#endif
104109
break;
110+
}
105111
case SOF_DAI_MEDIATEK_AFE:
106112
handshake = dai_get_handshake(dd->dai, dai->direction,
107113
dd->stream_id);
@@ -209,9 +215,15 @@ int ipc_dai_data_config(struct dai_data *dd, struct comp_dev *dev)
209215
}
210216
pin_data->pin_num = dd->dai->index;
211217
pin_data->pin_dir = dai->direction;
212-
pin_data->dma_channel = dd->chan ? dd->chan->index : 0xFFFF;
213-
pin_data->index = 0xFFFF;
214-
pin_data->instance = 0xFFFF;
218+
pin_data->dma_channel = dd->chan ? dd->chan->index : DAI_INDEX_INVALID;
219+
#if defined(CONFIG_SOC_ACP_7_X)
220+
for (int i = 0; i < SDW_INSTANCES; i++) {
221+
pin_data->index[i] = DAI_INDEX_INVALID;
222+
}
223+
#else
224+
pin_data->index = DAI_INDEX_INVALID;
225+
#endif
226+
pin_data->instance = DAI_INDEX_INVALID;
215227
dev_data->dai_index_ptr = pin_data;
216228
}
217229
#endif
@@ -310,6 +322,18 @@ void dai_dma_release(struct dai_data *dd, struct comp_dev *dev)
310322
return;
311323
}
312324

325+
#if defined(CONFIG_AMD)
326+
/* Free allocated DAI-specific data structures */
327+
if (dd->dma && dd->dma->z_dev && dd->dma->z_dev->data) {
328+
struct acp_dma_dev_data *dev_data = dd->dma->z_dev->data;
329+
330+
if (dev_data->dai_index_ptr) {
331+
rfree(dev_data->dai_index_ptr);
332+
dev_data->dai_index_ptr = NULL;
333+
}
334+
}
335+
#endif
336+
313337
/* put the allocated DMA channel first */
314338
if (dd->chan) {
315339
/* remove callback */

zephyr/lib/dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ SHARED_DATA struct sof_dma dma[] = {
212212
.z_dev = DEVICE_DT_GET(DT_NODELABEL(host_dma)),
213213
},
214214
#endif /* CONFIG_SOC_MIMX9596_M7 */
215-
#if defined(CONFIG_SOC_ACP_7_0)
215+
#if defined(CONFIG_SOC_ACP_7_0) || defined(CONFIG_SOC_ACP_7_X)
216216
{
217217
.plat_data = {
218218
.dir = SOF_DMA_DIR_LMEM_TO_HMEM |
@@ -233,7 +233,7 @@ SHARED_DATA struct sof_dma dma[] = {
233233
.caps = SOF_DMA_CAP_SW,
234234
.base = DMA0_BASE,
235235
.chan_size = DMA0_SIZE,
236-
.channels = 12,
236+
.channels = DT_PROP(DT_NODELABEL(acp_sdw_dma), dma_channels),
237237
.period_count = 2,
238238
},
239239
.z_dev = DEVICE_DT_GET(DT_NODELABEL(acp_sdw_dma)),

0 commit comments

Comments
 (0)