diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 344f7d74161..87c5b049036 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1694,6 +1694,10 @@ static int uart_stm32_init(const struct device *dev) * CONFIG_PM_DEVICE=y : Controlled by pm_device_wakeup_enable() */ LL_USART_EnableInStopMode(config->usart); + if (config->wakeup_line != STM32_EXTI_LINE_NONE) { + /* Prepare the WAKEUP with the expected EXTI line */ + LL_EXTI_EnableIT_0_31(BIT(config->wakeup_line)); + } } #endif /* CONFIG_PM */ @@ -1843,8 +1847,11 @@ static void uart_stm32_irq_config_func_##index(const struct device *dev) \ #endif #ifdef CONFIG_PM -#define STM32_UART_PM_WAKEUP(index) \ - .wakeup_source = DT_INST_PROP(index, wakeup_source), +#define STM32_UART_PM_WAKEUP(index) \ + .wakeup_source = DT_INST_PROP(index, wakeup_source), \ + .wakeup_line = COND_CODE_1(DT_INST_NODE_HAS_PROP(index, wakeup_line), \ + (DT_INST_PROP(index, wakeup_line)), \ + (STM32_EXTI_LINE_NONE)), #else #define STM32_UART_PM_WAKEUP(index) /* Not used */ #endif diff --git a/drivers/serial/uart_stm32.h b/drivers/serial/uart_stm32.h index cfa16204822..1d1f40b1d73 100644 --- a/drivers/serial/uart_stm32.h +++ b/drivers/serial/uart_stm32.h @@ -16,6 +16,8 @@ #include +#define STM32_EXTI_LINE_NONE 0xFFFFFFFFU + /* device config */ struct uart_stm32_config { /* USART instance */ @@ -44,6 +46,7 @@ struct uart_stm32_config { #if defined(CONFIG_PM) /* Device defined as wake-up source */ bool wakeup_source; + uint32_t wakeup_line; #endif /* CONFIG_PM */ };