Skip to content

Commit 9fcaaf6

Browse files
committed
drivers: dma: dma_mcux_lpc: Support power device constraint
Call pm_policy_device_power_lock_put/pm_policy_device_power_lock_get to coordinate with system level power modes. Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
1 parent 1ddc69f commit 9fcaaf6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/dma/dma_mcux_lpc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <zephyr/sys/util_macro.h>
2424
#include <zephyr/drivers/dma/dma_mcux_lpc.h>
2525
#include <zephyr/pm/device.h>
26+
#include <zephyr/pm/policy.h>
2627

2728
#define DT_DRV_COMPAT nxp_lpc_dma
2829

@@ -108,6 +109,10 @@ static void nxp_lpc_dma_callback(dma_handle_t *handle, void *param,
108109
ret = DMA_STATUS_COMPLETE;
109110
}
110111

112+
if (!data->busy) {
113+
pm_policy_device_power_lock_put(data->dev);
114+
}
115+
111116
if (data->dma_callback) {
112117
data->dma_callback(data->dev, data->user_data, channel, ret);
113118
}
@@ -563,6 +568,7 @@ static int dma_mcux_lpc_configure(const struct device *dev, uint32_t channel,
563568

564569
if (data->busy) {
565570
DMA_AbortTransfer(p_handle);
571+
pm_policy_device_power_lock_put(dev);
566572
}
567573

568574
LOG_DBG("channel is %d", p_handle->channel);
@@ -815,6 +821,7 @@ static int dma_mcux_lpc_start(const struct device *dev, uint32_t channel)
815821
LOG_DBG("START TRANSFER");
816822
LOG_DBG("DMA CTRL 0x%x", DEV_BASE(dev)->CTRL);
817823
data->busy = true;
824+
pm_policy_device_power_lock_get(dev);
818825
/* In case of a restart after a stop, reinstall the DMA callback
819826
* that was removed by the stop.
820827
*/
@@ -836,7 +843,10 @@ static int dma_mcux_lpc_stop(const struct device *dev, uint32_t channel)
836843
DMA_AbortTransfer(p_handle);
837844
DMA_DisableChannel(DEV_BASE(dev), p_handle->channel);
838845

839-
data->busy = false;
846+
if (data->busy) {
847+
data->busy = false;
848+
pm_policy_device_power_lock_put(dev);
849+
}
840850

841851
/* Handle race condition where if this is called from an ISR
842852
* and the DMA channel completion interrupt becomes pending

0 commit comments

Comments
 (0)