From 136207dc4430efc4f824f6bbd4230524a6c7252d Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Tue, 19 Nov 2024 15:35:41 +0100 Subject: [PATCH] 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 --- drivers/dma/dma_intel_adsp_gpdma.c | 41 +++++++++++------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/dma/dma_intel_adsp_gpdma.c b/drivers/dma/dma_intel_adsp_gpdma.c index bed6296adf8fd12..2f5e7e41023627f 100644 --- a/drivers/dma/dma_intel_adsp_gpdma.c +++ b/drivers/dma/dma_intel_adsp_gpdma.c @@ -440,38 +440,15 @@ static inline void ace_gpdma_intc_unmask(void) static inline void ace_gpdma_intc_unmask(void) {} #endif - -int intel_adsp_gpdma_init(const struct device *dev) -{ - struct dw_dma_dev_data *const dev_data = dev->data; - - /* Setup context and atomics for channels */ - dev_data->dma_ctx.magic = DMA_MAGIC; - dev_data->dma_ctx.dma_channels = DW_MAX_CHAN; - dev_data->dma_ctx.atomic = dev_data->channels_atomic; - - ace_gpdma_intc_unmask(); - -#if CONFIG_PM_DEVICE && CONFIG_SOC_SERIES_INTEL_ADSP_ACE - if (pm_device_on_power_domain(dev)) { - pm_device_init_off(dev); - } else { - pm_device_init_suspended(dev); - } - - return 0; -#else - return intel_adsp_gpdma_power_on(dev); -#endif -} -#ifdef CONFIG_PM_DEVICE static int gpdma_pm_action(const struct device *dev, enum pm_device_action action) { switch (action) { case PM_DEVICE_ACTION_RESUME: return intel_adsp_gpdma_power_on(dev); case PM_DEVICE_ACTION_SUSPEND: +#ifdef CONFIG_PM_DEVICE return intel_adsp_gpdma_power_off(dev); +#endif /* ON and OFF actions are used only by the power domain to change internal power status of * the device. OFF state mean that device and its power domain are disabled, SUSPEND mean * 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 return 0; } -#endif + +int intel_adsp_gpdma_init(const struct device *dev) +{ + struct dw_dma_dev_data *const dev_data = dev->data; + + /* Setup context and atomics for channels */ + dev_data->dma_ctx.magic = DMA_MAGIC; + dev_data->dma_ctx.dma_channels = DW_MAX_CHAN; + dev_data->dma_ctx.atomic = dev_data->channels_atomic; + + ace_gpdma_intc_unmask(); + return pm_device_driver_init(dev, gpdma_pm_action); +} static const struct dma_driver_api intel_adsp_gpdma_driver_api = { .config = intel_adsp_gpdma_config,