Skip to content

Commit 8a3dc68

Browse files
mmahadevan108kartben
authored andcommitted
soc: nxp_rw6xx: Add code to fire the GPIO callback
Call the API provided to fire a GPIO interrupt if registered on wakeup from PM Mode 3. Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 0cd23dc commit 8a3dc68

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

soc/nxp/rw/power.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <zephyr/pm/pm.h>
88
#include <zephyr/init.h>
99
#include <zephyr/drivers/pinctrl.h>
10+
#if CONFIG_GPIO && (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin0)) || \
11+
DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin1)))
12+
#include <zephyr/drivers/gpio/gpio_mcux_lpc.h>
13+
#endif
1014

1115
#include "fsl_power.h"
1216

@@ -34,6 +38,9 @@ power_sleep_config_t slp_cfg;
3438

3539
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin0)) || DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin1))
3640
pinctrl_soc_pin_t pin_cfg;
41+
#if CONFIG_GPIO
42+
const struct device *gpio;
43+
#endif
3744
#endif
3845

3946
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin0))
@@ -206,6 +213,15 @@ __weak void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
206213
ARG_UNUSED(state);
207214
ARG_UNUSED(substate_id);
208215

216+
#if CONFIG_GPIO && (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin0)) || \
217+
DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin1)))
218+
if (state == PM_STATE_STANDBY) {
219+
/* GPIO_0_24 & GPIO_0_25 are used for wakeup */
220+
uint32_t pins = PMU->WAKEUP_STATUS &
221+
(PMU_WAKEUP_STATUS_PIN0_MASK | PMU_WAKEUP_STATUS_PIN1_MASK);
222+
gpio_mcux_lpc_trigger_cb(gpio, (pins << 24));
223+
}
224+
#endif
209225
/* Clear PRIMASK */
210226
__enable_irq();
211227
}
@@ -247,4 +263,12 @@ void nxp_rw6xx_power_init(void)
247263
/* Clear the RTC wakeup bits */
248264
POWER_ClearWakeupStatus(DT_IRQN(DT_NODELABEL(rtc)));
249265
POWER_DisableWakeup(DT_IRQN(DT_NODELABEL(rtc)));
266+
267+
#if CONFIG_GPIO && (DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin0)) || \
268+
DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pin1)))
269+
gpio = DEVICE_DT_GET(DT_NODELABEL(hsgpio0));
270+
if (!device_is_ready(gpio)) {
271+
return;
272+
}
273+
#endif
250274
}

0 commit comments

Comments
 (0)