Counter_mcux_ctimer: Adds PM low-power recovery support
Enables Sleep mode (PM3) in RW61x for Ctimer. Signed-off-by: Tsi-Chung Liew <Tsi-Chung.Liew@nxp.com>
This commit is contained in:
parent
222e0fcd06
commit
8ac0a675ee
1 changed files with 31 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <zephyr/drivers/clock_control.h>
|
||||
#include <zephyr/dt-bindings/clock/mcux_lpc_syscon_clock.h>
|
||||
#include <zephyr/irq.h>
|
||||
#include <zephyr/pm/device.h>
|
||||
|
||||
LOG_MODULE_REGISTER(mcux_ctimer, CONFIG_COUNTER_LOG_LEVEL);
|
||||
|
||||
|
@ -248,7 +249,7 @@ static void mcux_lpc_ctimer_isr(const struct device *dev)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int mcux_lpc_ctimer_init(const struct device *dev)
|
||||
static int mcux_lpc_ctimer_init_common(const struct device *dev)
|
||||
{
|
||||
const struct mcux_lpc_ctimer_config *config = dev->config;
|
||||
struct mcux_lpc_ctimer_data *data = dev->data;
|
||||
|
@ -277,6 +278,32 @@ static int mcux_lpc_ctimer_init(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_lpc_ctimer_pm_action(const struct device *dev, enum pm_device_action action)
|
||||
{
|
||||
switch (action) {
|
||||
case PM_DEVICE_ACTION_RESUME:
|
||||
break;
|
||||
case PM_DEVICE_ACTION_SUSPEND:
|
||||
break;
|
||||
case PM_DEVICE_ACTION_TURN_OFF:
|
||||
break;
|
||||
case PM_DEVICE_ACTION_TURN_ON:
|
||||
mcux_lpc_ctimer_init_common(dev);
|
||||
break;
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_lpc_ctimer_init(const struct device *dev)
|
||||
{
|
||||
/* Rest of the init is done from the PM_DEVICE_TURN_ON action
|
||||
* which is invoked by pm_device_driver_init().
|
||||
*/
|
||||
return pm_device_driver_init(dev, mcux_lpc_ctimer_pm_action);
|
||||
}
|
||||
|
||||
static DEVICE_API(counter, mcux_ctimer_driver_api) = {
|
||||
.start = mcux_lpc_ctimer_start,
|
||||
.stop = mcux_lpc_ctimer_stop,
|
||||
|
@ -306,8 +333,10 @@ static DEVICE_API(counter, mcux_ctimer_driver_api) = {
|
|||
.prescale = DT_INST_PROP(id, prescale), \
|
||||
.irq_config_func = mcux_lpc_ctimer_irq_config_##id, \
|
||||
}; \
|
||||
PM_DEVICE_DT_INST_DEFINE(id, mcux_lpc_ctimer_pm_action); \
|
||||
static struct mcux_lpc_ctimer_data mcux_lpc_ctimer_data_##id; \
|
||||
DEVICE_DT_INST_DEFINE(id, &mcux_lpc_ctimer_init, NULL, &mcux_lpc_ctimer_data_##id, \
|
||||
DEVICE_DT_INST_DEFINE(id, &mcux_lpc_ctimer_init, PM_DEVICE_DT_INST_GET(id), \
|
||||
&mcux_lpc_ctimer_data_##id, \
|
||||
&mcux_lpc_ctimer_config_##id, POST_KERNEL, \
|
||||
CONFIG_COUNTER_INIT_PRIORITY, &mcux_ctimer_driver_api); \
|
||||
static void mcux_lpc_ctimer_irq_config_##id(const struct device *dev) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue