Skip to content

Commit 0ac614f

Browse files
committed
driver: dma: dma_silabs_siwx91x: Add pm device support for dma driver
This commit enables the pm device driver support for the dma_silabs_siwx91x driver. Signed-off-by: S Mohamed Fiaz <[email protected]>
1 parent add9e60 commit 0ac614f

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

drivers/dma/dma_silabs_siwx91x.c

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <zephyr/drivers/dma.h>
1414
#include <zephyr/drivers/clock_control.h>
1515
#include <zephyr/logging/log.h>
16+
#include <zephyr/pm/device.h>
1617
#include <zephyr/types.h>
1718
#include "rsi_rom_udma.h"
1819
#include "rsi_rom_udma_wrapper.h"
@@ -560,8 +561,7 @@ bool siwx91x_dma_chan_filter(const struct device *dev, int channel, void *filter
560561
}
561562
}
562563

563-
/* Function to initialize DMA peripheral */
564-
static int siwx91x_dma_init(const struct device *dev)
564+
static int dma_siwx91x_pm_action(const struct device *dev, enum pm_device_action action)
565565
{
566566
const struct dma_siwx91x_config *cfg = dev->config;
567567
struct dma_siwx91x_data *data = dev->data;
@@ -573,27 +573,39 @@ static int siwx91x_dma_init(const struct device *dev)
573573
};
574574
int ret;
575575

576-
ret = clock_control_on(cfg->clock_dev, cfg->clock_subsys);
577-
if (ret) {
578-
return ret;
579-
}
576+
if (action == PM_DEVICE_ACTION_RESUME) {
577+
ret = clock_control_on(cfg->clock_dev, cfg->clock_subsys);
578+
if (ret) {
579+
return ret;
580+
}
580581

581-
udma_handle = UDMAx_Initialize(&udma_resources, udma_resources.desc, NULL,
582-
(uint32_t *)&data->udma_handle);
583-
if (udma_handle != &data->udma_handle) {
584-
return -EINVAL;
585-
}
582+
udma_handle = UDMAx_Initialize(&udma_resources, udma_resources.desc, NULL,
583+
(uint32_t *)&data->udma_handle);
584+
if (udma_handle != &data->udma_handle) {
585+
return -EINVAL;
586+
}
586587

587-
/* Connect the DMA interrupt */
588-
cfg->irq_configure();
588+
/* Connect the DMA interrupt */
589+
cfg->irq_configure();
589590

590-
if (UDMAx_DMAEnable(&udma_resources, udma_handle) != 0) {
591-
return -EBUSY;
591+
if (UDMAx_DMAEnable(&udma_resources, udma_handle) != 0) {
592+
return -EBUSY;
593+
}
594+
} else if (IS_ENABLED(CONFIG_PM_DEVICE) && (action == PM_DEVICE_ACTION_SUSPEND)) {
595+
return 0;
596+
} else {
597+
return -ENOTSUP;
592598
}
593599

594600
return 0;
595601
}
596602

603+
/* Function to initialize DMA peripheral */
604+
static int siwx91x_dma_init(const struct device *dev)
605+
{
606+
return pm_device_driver_init(dev, dma_siwx91x_pm_action);
607+
}
608+
597609
static void siwx91x_dma_isr(const struct device *dev)
598610
{
599611
const struct dma_siwx91x_config *cfg = dev->config;
@@ -701,7 +713,10 @@ static DEVICE_API(dma, siwx91x_dma_api) = {
701713
(siwx91x_dma_chan_desc##inst)), \
702714
.irq_configure = siwx91x_dma_irq_configure_##inst, \
703715
}; \
704-
DEVICE_DT_INST_DEFINE(inst, siwx91x_dma_init, NULL, &dma_data_##inst, &dma_cfg_##inst, \
705-
POST_KERNEL, CONFIG_DMA_INIT_PRIORITY, &siwx91x_dma_api);
716+
PM_DEVICE_DT_INST_DEFINE(inst, dma_siwx91x_pm_action); \
717+
DEVICE_DT_INST_DEFINE(inst, siwx91x_dma_init, PM_DEVICE_DT_INST_GET(inst), \
718+
&dma_data_##inst, &dma_cfg_##inst, POST_KERNEL, \
719+
CONFIG_DMA_INIT_PRIORITY, \
720+
&siwx91x_dma_api);
706721

707722
DT_INST_FOREACH_STATUS_OKAY(SIWX91X_DMA_INIT)

0 commit comments

Comments
 (0)