-
Notifications
You must be signed in to change notification settings - Fork 8k
driver: dma: dma_silabs_siwx91x: Add pm device support for dma driver #94374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include <zephyr/drivers/dma.h> | ||
#include <zephyr/drivers/clock_control.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/pm/device.h> | ||
#include <zephyr/types.h> | ||
#include "rsi_rom_udma.h" | ||
#include "rsi_rom_udma_wrapper.h" | ||
|
@@ -560,8 +561,7 @@ bool siwx91x_dma_chan_filter(const struct device *dev, int channel, void *filter | |
} | ||
} | ||
|
||
/* Function to initialize DMA peripheral */ | ||
static int siwx91x_dma_init(const struct device *dev) | ||
static int dma_siwx91x_pm_action(const struct device *dev, enum pm_device_action action) | ||
{ | ||
const struct dma_siwx91x_config *cfg = dev->config; | ||
struct dma_siwx91x_data *data = dev->data; | ||
|
@@ -573,27 +573,48 @@ static int siwx91x_dma_init(const struct device *dev) | |
}; | ||
int ret; | ||
|
||
ret = clock_control_on(cfg->clock_dev, cfg->clock_subsys); | ||
if (ret) { | ||
return ret; | ||
} | ||
switch (action) { | ||
case PM_DEVICE_ACTION_RESUME: | ||
break; | ||
case PM_DEVICE_ACTION_SUSPEND: | ||
break; | ||
case PM_DEVICE_ACTION_TURN_ON: | ||
ret = clock_control_on(cfg->clock_dev, cfg->clock_subsys); | ||
if (ret < 0 && ret != -EALREADY) { | ||
return ret; | ||
} | ||
|
||
udma_handle = UDMAx_Initialize(&udma_resources, udma_resources.desc, NULL, | ||
(uint32_t *)&data->udma_handle); | ||
if (udma_handle != &data->udma_handle) { | ||
return -EINVAL; | ||
} | ||
udma_handle = UDMAx_Initialize(&udma_resources, udma_resources.desc, NULL, | ||
(uint32_t *)&data->udma_handle); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think I believe Device runtime PM will only play with I assume System Managed PM (or power domains) won't retains the registers but it will call @Martinhoff-maker, @asmellby, can you confirm my understanding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed |
||
if (udma_handle != &data->udma_handle) { | ||
return -EINVAL; | ||
} | ||
|
||
/* Connect the DMA interrupt */ | ||
cfg->irq_configure(); | ||
cfg->irq_configure(); | ||
|
||
if (UDMAx_DMAEnable(&udma_resources, udma_handle) != 0) { | ||
return -EBUSY; | ||
if (UDMAx_DMAEnable(&udma_resources, udma_handle) != 0) { | ||
return -EBUSY; | ||
} | ||
break; | ||
case PM_DEVICE_ACTION_TURN_OFF: | ||
ret = clock_control_off(cfg->clock_dev, cfg->clock_subsys); | ||
if (ret < 0 && ret != -EALREADY) { | ||
return ret; | ||
} | ||
break; | ||
default: | ||
return -ENOTSUP; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/* Function to initialize DMA peripheral */ | ||
static int siwx91x_dma_init(const struct device *dev) | ||
{ | ||
return pm_device_driver_init(dev, dma_siwx91x_pm_action); | ||
jerome-pouiller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
static void siwx91x_dma_isr(const struct device *dev) | ||
{ | ||
const struct dma_siwx91x_config *cfg = dev->config; | ||
|
@@ -701,7 +722,10 @@ static DEVICE_API(dma, siwx91x_dma_api) = { | |
(siwx91x_dma_chan_desc##inst)), \ | ||
.irq_configure = siwx91x_dma_irq_configure_##inst, \ | ||
}; \ | ||
DEVICE_DT_INST_DEFINE(inst, siwx91x_dma_init, NULL, &dma_data_##inst, &dma_cfg_##inst, \ | ||
POST_KERNEL, CONFIG_DMA_INIT_PRIORITY, &siwx91x_dma_api); | ||
PM_DEVICE_DT_INST_DEFINE(inst, dma_siwx91x_pm_action); \ | ||
DEVICE_DT_INST_DEFINE(inst, siwx91x_dma_init, PM_DEVICE_DT_INST_GET(inst), \ | ||
&dma_data_##inst, &dma_cfg_##inst, POST_KERNEL, \ | ||
CONFIG_DMA_INIT_PRIORITY, \ | ||
&siwx91x_dma_api); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(SIWX91X_DMA_INIT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to turn this clock in
PM_DEVICE_ACTION_TURN_ON
, or this can be done later inPM_DEVICE_ACTION_RESUME
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was discussed to place it here