drivers: counter: Update NXP LPC RTC for wakeup source
Add support to wakeup from low power modes Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This commit is contained in:
parent
6e688980a3
commit
3f38b011c3
1 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, NXP
|
* Copyright 2021-22, NXP
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
#include <zephyr/drivers/counter.h>
|
#include <zephyr/drivers/counter.h>
|
||||||
#include <zephyr/irq.h>
|
#include <zephyr/irq.h>
|
||||||
#include <fsl_rtc.h>
|
#include <fsl_rtc.h>
|
||||||
|
#include "fsl_power.h"
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(mcux_rtc, CONFIG_COUNTER_LOG_LEVEL);
|
LOG_MODULE_REGISTER(mcux_rtc, CONFIG_COUNTER_LOG_LEVEL);
|
||||||
|
@ -24,6 +25,8 @@ struct mcux_lpc_rtc_config {
|
||||||
struct counter_config_info info;
|
struct counter_config_info info;
|
||||||
RTC_Type *base;
|
RTC_Type *base;
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
|
/* Device defined as wake-up source */
|
||||||
|
bool wakeup_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mcux_lpc_rtc_start(const struct device *dev)
|
static int mcux_lpc_rtc_start(const struct device *dev)
|
||||||
|
@ -209,6 +212,11 @@ static int mcux_lpc_rtc_init(const struct device *dev)
|
||||||
|
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
|
|
||||||
|
if (config->wakeup_source) {
|
||||||
|
/* Enable the bit to wakeup from Deep Power Down mode */
|
||||||
|
RTC_EnableAlarmTimerInterruptFromDPD(config->base, true);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +242,7 @@ static const struct counter_driver_api mcux_rtc_driver_api = {
|
||||||
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
|
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
|
||||||
.channels = 1, \
|
.channels = 1, \
|
||||||
}, \
|
}, \
|
||||||
|
.wakeup_source = DT_INST_PROP(id, wakeup_source) \
|
||||||
}; \
|
}; \
|
||||||
static struct mcux_lpc_rtc_data mcux_lpc_rtc_data_##id; \
|
static struct mcux_lpc_rtc_data mcux_lpc_rtc_data_##id; \
|
||||||
DEVICE_DT_INST_DEFINE(id, &mcux_lpc_rtc_init, NULL, \
|
DEVICE_DT_INST_DEFINE(id, &mcux_lpc_rtc_init, NULL, \
|
||||||
|
@ -246,6 +255,9 @@ static const struct counter_driver_api mcux_rtc_driver_api = {
|
||||||
DT_INST_IRQ(id, priority), \
|
DT_INST_IRQ(id, priority), \
|
||||||
mcux_lpc_rtc_isr, DEVICE_DT_INST_GET(id), 0); \
|
mcux_lpc_rtc_isr, DEVICE_DT_INST_GET(id), 0); \
|
||||||
irq_enable(DT_INST_IRQN(id)); \
|
irq_enable(DT_INST_IRQN(id)); \
|
||||||
|
if (DT_INST_PROP(id, wakeup_source)) { \
|
||||||
|
EnableDeepSleepIRQ(DT_INST_IRQN(id)); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(COUNTER_LPC_RTC_DEVICE)
|
DT_INST_FOREACH_STATUS_OKAY(COUNTER_LPC_RTC_DEVICE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue