Skip to content

Commit

Permalink
drivers: gpdma: Refactor power management initialization
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tmleman committed Dec 4, 2024
1 parent 66fa0ff commit 136207d
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions drivers/dma/dma_intel_adsp_gpdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down

0 comments on commit 136207d

Please sign in to comment.