1 /*
2  * Copyright (c) 2022 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #define DT_DRV_COMPAT intel_adsp_hda_host_in
8 
9 #include <zephyr/drivers/dma.h>
10 #include <adsp_interrupt.h>
11 #include "dma_intel_adsp_hda.h"
12 
13 static const struct dma_driver_api intel_adsp_hda_dma_host_in_api = {
14 	.config = intel_adsp_hda_dma_host_in_config,
15 	.reload = intel_adsp_hda_dma_host_reload,
16 	.start = intel_adsp_hda_dma_start,
17 	.stop = intel_adsp_hda_dma_stop,
18 	.get_status = intel_adsp_hda_dma_status,
19 	.get_attribute = intel_adsp_hda_dma_get_attribute,
20 	.chan_filter = intel_adsp_hda_dma_chan_filter,
21 };
22 
23 #define INTEL_ADSP_HDA_DMA_HOST_IN_INIT(inst)                                                      \
24 	static void intel_adsp_hda_dma##inst##_irq_config(void);				   \
25 									                           \
26 	static const struct intel_adsp_hda_dma_cfg intel_adsp_hda_dma##inst##_config = {           \
27 		.base = DT_INST_REG_ADDR(inst),                                                    \
28 		.regblock_size  = DT_INST_REG_SIZE(inst),					   \
29 		.dma_channels = DT_INST_PROP(inst, dma_channels),                                  \
30 		.direction = MEMORY_TO_HOST,                                                       \
31 		.irq_config = intel_adsp_hda_dma##inst##_irq_config				   \
32 	};                                                                                         \
33 												   \
34 	static struct intel_adsp_hda_dma_data intel_adsp_hda_dma##inst##_data = {};                \
35 												   \
36 	PM_DEVICE_DT_INST_DEFINE(inst, intel_adsp_hda_dma_pm_action);				   \
37 												   \
38 	DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init,					   \
39 			      PM_DEVICE_DT_INST_GET(inst),					   \
40 			      &intel_adsp_hda_dma##inst##_data,                                    \
41 			      &intel_adsp_hda_dma##inst##_config, POST_KERNEL,                     \
42 			      CONFIG_DMA_INIT_PRIORITY,                                            \
43 			      &intel_adsp_hda_dma_host_in_api);		\
44 									\
45 	static void intel_adsp_hda_dma##inst##_irq_config(void)		\
46 	{								\
47 		IRQ_CONNECT(DT_INST_IRQN(inst),			\
48 			    DT_INST_IRQ(inst, priority), intel_adsp_hda_dma_isr,	\
49 			    DEVICE_DT_INST_GET(inst),			\
50 			    DT_INST_IRQ(inst, sense));			\
51 		irq_enable(DT_INST_IRQN(inst));			\
52 		IF_ENABLED(CONFIG_SOC_SERIES_INTEL_ACE, (ACE_DINT[0].ie[ACE_INTL_HDAHIDMA] = 1;)) \
53 	}
54 
55 DT_INST_FOREACH_STATUS_OKAY(INTEL_ADSP_HDA_DMA_HOST_IN_INIT)
56