Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: serial: stm32u5: Serial wakeup is based on autonomous capability #65532

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions drivers/serial/uart_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {

Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2023 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

&cpu0{
fabiobaltieri marked this conversation as resolved.
Show resolved Hide resolved
/* USART Wakeup requires automatic HSI16 switch on in deepsleep mode
* which isn't possible in Stop Mode 2.
* Remove Stop Mode 2 from supported modes
*/
cpu-power-states = <&stop0 &stop1>;
};

&usart1 {
/* Set domain clock to HSI to allow wakeup from Stop mode */
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00004000>,
<&rcc STM32_SRC_HSI16 USART1_SEL(2)>;

/* Configure device as wakeup source */
wakeup-source;

/* Configure sleep pinctrl configuration which will be used when
* device is not configured as wakeup source by the application.
* This use case is only applicable in PM_DEVICE mode.
*/
pinctrl-1 = <&analog_pa9 &analog_pa10>;
pinctrl-names = "default", "sleep";
};

&clk_hsi {
/* Make sure HSI is enabled */
status = "okay";
};
Loading