Skip to content

Commit 6698f3b

Browse files
mmahadevan108kartben
authored andcommitted
drivers: dma: Add PM handler for NXP LPC DMA driver
Add the PM handler. Reinitialize the DMA block in the TURN_ON action, this is needed for some SoC's after the system exits certain power modes. Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
1 parent 5379f4a commit 6698f3b

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

drivers/dma/dma_mcux_lpc.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <zephyr/sys/util.h>
2020
#include <zephyr/sys/util_macro.h>
2121
#include <zephyr/drivers/dma/dma_mcux_lpc.h>
22+
#include <zephyr/pm/device.h>
2223

2324
#define DT_DRV_COMPAT nxp_lpc_dma
2425

@@ -845,6 +846,26 @@ static int dma_mcux_lpc_get_attribute(const struct device *dev, uint32_t type, u
845846
return 0;
846847
}
847848

849+
static int dma_mcux_lpc_pm_action(const struct device *dev, enum pm_device_action action)
850+
{
851+
switch (action) {
852+
case PM_DEVICE_ACTION_RESUME:
853+
break;
854+
case PM_DEVICE_ACTION_SUSPEND:
855+
break;
856+
case PM_DEVICE_ACTION_TURN_OFF:
857+
break;
858+
case PM_DEVICE_ACTION_TURN_ON:
859+
DMA_Init(DEV_BASE(dev));
860+
INPUTMUX_Init(INPUTMUX);
861+
break;
862+
default:
863+
return -ENOTSUP;
864+
}
865+
866+
return 0;
867+
}
868+
848869
static int dma_mcux_lpc_init(const struct device *dev)
849870
{
850871
const struct dma_mcux_lpc_config *config = dev->config;
@@ -869,12 +890,12 @@ static int dma_mcux_lpc_init(const struct device *dev)
869890

870891
data->num_channels_used = 0;
871892

872-
DMA_Init(DEV_BASE(dev));
873-
INPUTMUX_Init(INPUTMUX);
874-
875893
config->irq_config_func(dev);
876894

877-
return 0;
895+
/* Complete the remaining hardware specific init in the TURN_ON action
896+
* of the power management handler.
897+
*/
898+
return pm_device_driver_init(dev, dma_mcux_lpc_pm_action);
878899
}
879900

880901
static DEVICE_API(dma, dma_mcux_lpc_api) = {
@@ -937,9 +958,11 @@ static const struct dma_mcux_lpc_config dma_##n##_config = { \
937958
.otrig_array = dma_##n##_otrig_arr, \
938959
}; \
939960
\
961+
PM_DEVICE_DT_INST_DEFINE(n, dma_mcux_lpc_pm_action); \
962+
\
940963
DEVICE_DT_INST_DEFINE(n, \
941964
dma_mcux_lpc_init, \
942-
NULL, \
965+
PM_DEVICE_DT_INST_GET(n), \
943966
&dma_data_##n, &dma_##n##_config, \
944967
PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, \
945968
&dma_mcux_lpc_api); \

0 commit comments

Comments
 (0)