From a38c8d25e7b387ead1ded76d372c918e3147ba4c Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Tue, 21 Nov 2023 16:59:27 +0100 Subject: [PATCH] drivers: serial: stm32u5: Serial wakeup is based on autonomous capability On some devices such as STM32U5, there is no UART WKUP dedicated registers as the hardware block has an integrated autonomous wakeup capability. Hence it's capable to wake up the device from stop modes (down to Stop 1). This behavior relies on RCC UESM bit which is enabled by default at reset and not modified today in drivers. Since driver will not compile otherwise, remain in this simple configuration. This might be changed later on, if a need is seen to disable UESM bit. Signed-off-by: Erwan Gouriou --- drivers/serial/uart_stm32.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index dd79612322d..097ba70c1b6 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1279,7 +1279,8 @@ static void uart_stm32_isr(const struct device *dev) uart_stm32_err_check(dev); #endif /* CONFIG_UART_ASYNC_API */ -#ifdef CONFIG_PM +#if defined(CONFIG_PM) && defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE) \ + && defined(USART_CR3_WUFIE) if (LL_USART_IsEnabledIT_WKUP(config->usart) && LL_USART_IsActiveFlag_WKUP(config->usart)) { @@ -2017,13 +2018,14 @@ static int uart_stm32_init(const struct device *dev) * CONFIG_PM_DEVICE=n : Always active * CONFIG_PM_DEVICE=y : Controlled by pm_device_wakeup_enable() */ - +#ifdef USART_CR3_WUFIE LL_USART_Disable(config->usart); LL_USART_SetWKUPType(config->usart, LL_USART_WAKEUP_ON_RXNE); LL_USART_EnableIT_WKUP(config->usart); LL_USART_ClearFlag_WKUP(config->usart); - LL_USART_EnableInStopMode(config->usart); LL_USART_Enable(config->usart); +#endif + LL_USART_EnableInStopMode(config->usart); if (config->wakeup_line != STM32_EXTI_LINE_NONE) { /* Prepare the WAKEUP with the expected EXTI line */