diff --git a/drivers/dma/dma_intel_adsp_hda.c b/drivers/dma/dma_intel_adsp_hda.c index af5adbce784..5e68b347ad9 100644 --- a/drivers/dma/dma_intel_adsp_hda.c +++ b/drivers/dma/dma_intel_adsp_hda.c @@ -236,7 +236,7 @@ int intel_adsp_hda_dma_start(const struct device *dev, uint32_t channel) intel_adsp_hda_link_commit(cfg->base, cfg->regblock_size, channel, size); } - return 0; + return pm_device_runtime_get(dev); } int intel_adsp_hda_dma_stop(const struct device *dev, uint32_t channel) @@ -247,7 +247,7 @@ int intel_adsp_hda_dma_stop(const struct device *dev, uint32_t channel) intel_adsp_hda_disable(cfg->base, cfg->regblock_size, channel); - return 0; + return pm_device_runtime_put(dev); } int intel_adsp_hda_dma_init(const struct device *dev) @@ -263,7 +263,8 @@ int intel_adsp_hda_dma_init(const struct device *dev) data->ctx.atomic = data->channels_atomic; data->ctx.magic = DMA_MAGIC; - return 0; + pm_device_init_suspended(dev); + return pm_device_runtime_enable(dev); } int intel_adsp_hda_dma_get_attribute(const struct device *dev, uint32_t type, uint32_t *value) @@ -289,3 +290,20 @@ int intel_adsp_hda_dma_get_attribute(const struct device *dev, uint32_t type, ui return 0; } + +#ifdef CONFIG_PM_DEVICE +int intel_adsp_hda_dma_pm_action(const struct device *dev, enum pm_device_action action) +{ + switch (action) { + case PM_DEVICE_ACTION_SUSPEND: + case PM_DEVICE_ACTION_RESUME: + case PM_DEVICE_ACTION_TURN_ON: + case PM_DEVICE_ACTION_TURN_OFF: + break; + default: + return -ENOTSUP; + } + + return 0; +} +#endif diff --git a/drivers/dma/dma_intel_adsp_hda.h b/drivers/dma/dma_intel_adsp_hda.h index cc4dedeba38..4638732a8ac 100644 --- a/drivers/dma/dma_intel_adsp_hda.h +++ b/drivers/dma/dma_intel_adsp_hda.h @@ -10,6 +10,8 @@ #define INTEL_ADSP_HDA_MAX_CHANNELS DT_PROP(DT_NODELABEL(hda_host_out), dma_channels) #include +#include +#include struct intel_adsp_hda_dma_data { struct dma_context ctx; @@ -60,4 +62,8 @@ int intel_adsp_hda_dma_init(const struct device *dev); int intel_adsp_hda_dma_get_attribute(const struct device *dev, uint32_t type, uint32_t *value); +#ifdef CONFIG_PM_DEVICE +int intel_adsp_hda_dma_pm_action(const struct device *dev, enum pm_device_action action); +#endif + #endif /* ZEPHYR_DRIVERS_DMA_INTEL_ADSP_HDA_COMMON_H_ */ diff --git a/drivers/dma/dma_intel_adsp_hda_host_in.c b/drivers/dma/dma_intel_adsp_hda_host_in.c index c78f38a1b57..4fbf42e5328 100644 --- a/drivers/dma/dma_intel_adsp_hda_host_in.c +++ b/drivers/dma/dma_intel_adsp_hda_host_in.c @@ -29,7 +29,10 @@ static const struct dma_driver_api intel_adsp_hda_dma_host_in_api = { \ static struct intel_adsp_hda_dma_data intel_adsp_hda_dma##inst##_data = {}; \ \ - DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, NULL, \ + PM_DEVICE_DT_INST_DEFINE(inst, intel_adsp_hda_dma_pm_action); \ + \ + DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, \ + PM_DEVICE_DT_INST_GET(inst), \ &intel_adsp_hda_dma##inst##_data, \ &intel_adsp_hda_dma##inst##_config, POST_KERNEL, \ CONFIG_DMA_INIT_PRIORITY, \ diff --git a/drivers/dma/dma_intel_adsp_hda_host_out.c b/drivers/dma/dma_intel_adsp_hda_host_out.c index 80831d93fd5..efd85e93fe8 100644 --- a/drivers/dma/dma_intel_adsp_hda_host_out.c +++ b/drivers/dma/dma_intel_adsp_hda_host_out.c @@ -33,7 +33,10 @@ static const struct dma_driver_api intel_adsp_hda_dma_host_out_api = { \ static struct intel_adsp_hda_dma_data intel_adsp_hda_dma##inst##_data = {}; \ \ - DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, NULL, \ + PM_DEVICE_DT_INST_DEFINE(inst, intel_adsp_hda_dma_pm_action); \ + \ + DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, \ + PM_DEVICE_DT_INST_GET(inst), \ &intel_adsp_hda_dma##inst##_data, \ &intel_adsp_hda_dma##inst##_config, POST_KERNEL, \ CONFIG_DMA_INIT_PRIORITY, \ diff --git a/drivers/dma/dma_intel_adsp_hda_link_in.c b/drivers/dma/dma_intel_adsp_hda_link_in.c index f011b942524..8f415d6e57e 100644 --- a/drivers/dma/dma_intel_adsp_hda_link_in.c +++ b/drivers/dma/dma_intel_adsp_hda_link_in.c @@ -34,7 +34,10 @@ static const struct dma_driver_api intel_adsp_hda_dma_link_in_api = { \ static struct intel_adsp_hda_dma_data intel_adsp_hda_dma##inst##_data = {}; \ \ - DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, NULL, \ + PM_DEVICE_DT_INST_DEFINE(inst, intel_adsp_hda_dma_pm_action); \ + \ + DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, \ + PM_DEVICE_DT_INST_GET(inst), \ &intel_adsp_hda_dma##inst##_data, \ &intel_adsp_hda_dma##inst##_config, POST_KERNEL, \ CONFIG_DMA_INIT_PRIORITY, \ diff --git a/drivers/dma/dma_intel_adsp_hda_link_out.c b/drivers/dma/dma_intel_adsp_hda_link_out.c index 56d6ab9005c..03200539a56 100644 --- a/drivers/dma/dma_intel_adsp_hda_link_out.c +++ b/drivers/dma/dma_intel_adsp_hda_link_out.c @@ -34,7 +34,10 @@ static const struct dma_driver_api intel_adsp_hda_dma_link_out_api = { \ static struct intel_adsp_hda_dma_data intel_adsp_hda_dma##inst##_data = {}; \ \ - DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, NULL, \ + PM_DEVICE_DT_INST_DEFINE(inst, intel_adsp_hda_dma_pm_action); \ + \ + DEVICE_DT_INST_DEFINE(inst, &intel_adsp_hda_dma_init, \ + PM_DEVICE_DT_INST_GET(inst), \ &intel_adsp_hda_dma##inst##_data, \ &intel_adsp_hda_dma##inst##_config, POST_KERNEL, \ CONFIG_DMA_INIT_PRIORITY, \