Skip to content

Commit 02868b7

Browse files
committed
drivers: serial: Enable UART wake-up line in STM32
Enable UART wake-up line in STM32 driver. Signed-off-by: Ali Hozhabri <[email protected]>
1 parent 85f6d6b commit 02868b7

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

drivers/serial/uart_stm32.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <stm32_ll_usart.h>
3838
#include <stm32_ll_lpuart.h>
3939
#if defined(CONFIG_PM) && defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE)
40+
#include <stm32_ll_pwr.h>
4041
#include <stm32_ll_exti.h>
4142
#endif /* CONFIG_PM */
4243

@@ -111,6 +112,25 @@ static void uart_stm32_pm_policy_state_lock_get_unconditional(void)
111112
}
112113
}
113114

115+
static inline void uart_stm32_pm_enable_wakeup_line(uint32_t wakeup_line)
116+
{
117+
#if defined(CONFIG_SOC_SERIES_STM32WB0X)
118+
ARG_UNUSED(wakeup_line);
119+
#if defined(PWR_CR3_EIWL2)
120+
/**
121+
* If SoC is equipped with LPUART instance,
122+
* enable the associated wake-up line in PWRC.
123+
*/
124+
LL_PWR_EnableInternWU2();
125+
#endif /* PWR_CR3_EIWL2 */
126+
#elif defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE)
127+
if (wakeup_line != STM32_WAKEUP_LINE_NONE) {
128+
/* Enable EXTI line associated to UART wake-up event */
129+
LL_EXTI_EnableIT_0_31(BIT(wakeup_line));
130+
}
131+
#endif /* CONFIG_SOC_SERIES_STM32WB0X */
132+
}
133+
114134
static void uart_stm32_pm_policy_state_lock_get(const struct device *dev)
115135
{
116136
struct uart_stm32_data *data = dev->data;
@@ -2160,12 +2180,12 @@ static int uart_stm32_registers_configure(const struct device *dev)
21602180
LL_USART_EnableIT_WKUP(usart);
21612181
LL_USART_ClearFlag_WKUP(usart);
21622182
#endif
2183+
#if !defined(CONFIG_SOC_SERIES_STM32WB0X) || defined(USART_CR1_UESM)
21632184
LL_USART_EnableInStopMode(usart);
2185+
#endif /* !CONFIG_SOC_SERIES_STM32WB0X || USART_CR1_UESM */
21642186

2165-
if (config->wakeup_line != STM32_WAKEUP_LINE_NONE) {
2166-
/* Prepare the WAKEUP with the expected EXTI line */
2167-
LL_EXTI_EnableIT_0_31(BIT(config->wakeup_line));
2168-
}
2187+
/* Enable the wake-up line signal (if applicable to hardware) */
2188+
uart_stm32_pm_enable_wakeup_line(config->wakeup_line);
21692189
}
21702190
#endif /* CONFIG_PM */
21712191

0 commit comments

Comments
 (0)