Skip to content

Commit 9edca5e

Browse files
tmlemankartben
authored andcommitted
drivers: gpdma: Refactor power management initialization
This patch refactors the power management initialization for the Intel ADSP GPDMA driver. The changes include: 1. Replacing the conditional initialization of power management state with a call to `pm_device_driver_init` in the `intel_adsp_gpdma_init` function. 2. Ensuring that the GPDMA driver is initialized with the appropriate power management state and that runtime power management is automatically enabled based on the device tree configuration. These changes streamline the power management initialization process and ensure consistency with other drivers. Signed-off-by: Tomasz Leman <[email protected]>
1 parent fe2861b commit 9edca5e

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

drivers/dma/dma_intel_adsp_gpdma.c

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -440,38 +440,15 @@ static inline void ace_gpdma_intc_unmask(void)
440440
static inline void ace_gpdma_intc_unmask(void) {}
441441
#endif
442442

443-
444-
int intel_adsp_gpdma_init(const struct device *dev)
445-
{
446-
struct dw_dma_dev_data *const dev_data = dev->data;
447-
448-
/* Setup context and atomics for channels */
449-
dev_data->dma_ctx.magic = DMA_MAGIC;
450-
dev_data->dma_ctx.dma_channels = DW_MAX_CHAN;
451-
dev_data->dma_ctx.atomic = dev_data->channels_atomic;
452-
453-
ace_gpdma_intc_unmask();
454-
455-
#if CONFIG_PM_DEVICE && CONFIG_SOC_SERIES_INTEL_ADSP_ACE
456-
if (pm_device_on_power_domain(dev)) {
457-
pm_device_init_off(dev);
458-
} else {
459-
pm_device_init_suspended(dev);
460-
}
461-
462-
return 0;
463-
#else
464-
return intel_adsp_gpdma_power_on(dev);
465-
#endif
466-
}
467-
#ifdef CONFIG_PM_DEVICE
468443
static int gpdma_pm_action(const struct device *dev, enum pm_device_action action)
469444
{
470445
switch (action) {
471446
case PM_DEVICE_ACTION_RESUME:
472447
return intel_adsp_gpdma_power_on(dev);
473448
case PM_DEVICE_ACTION_SUSPEND:
449+
#ifdef CONFIG_PM_DEVICE
474450
return intel_adsp_gpdma_power_off(dev);
451+
#endif
475452
/* ON and OFF actions are used only by the power domain to change internal power status of
476453
* the device. OFF state mean that device and its power domain are disabled, SUSPEND mean
477454
* that device is power off but domain is already power on.
@@ -485,7 +462,19 @@ static int gpdma_pm_action(const struct device *dev, enum pm_device_action actio
485462

486463
return 0;
487464
}
488-
#endif
465+
466+
int intel_adsp_gpdma_init(const struct device *dev)
467+
{
468+
struct dw_dma_dev_data *const dev_data = dev->data;
469+
470+
/* Setup context and atomics for channels */
471+
dev_data->dma_ctx.magic = DMA_MAGIC;
472+
dev_data->dma_ctx.dma_channels = DW_MAX_CHAN;
473+
dev_data->dma_ctx.atomic = dev_data->channels_atomic;
474+
475+
ace_gpdma_intc_unmask();
476+
return pm_device_driver_init(dev, gpdma_pm_action);
477+
}
489478

490479
static const struct dma_driver_api intel_adsp_gpdma_driver_api = {
491480
.config = intel_adsp_gpdma_config,

0 commit comments

Comments
 (0)