Commit 9edca5e1 authored by Tomasz Leman's avatar Tomasz Leman Committed by Benjamin Cabé
Browse files

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: default avatarTomasz Leman <tomasz.m.leman@intel.com>
parent fe2861b5
Loading
Loading
Loading
Loading
+15 −26
Original line number Diff line number Diff line
@@ -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,