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 <erwan.gouriou@st.com>
diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c
index dd79612..097ba70 100644
--- a/drivers/serial/uart_stm32.c
+++ b/drivers/serial/uart_stm32.c
@@ -1279,7 +1279,8 @@
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 @@
* 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 */