|
38 | 38 | #include <stm32_ll_usart.h>
|
39 | 39 | #include <stm32_ll_lpuart.h>
|
40 | 40 | #if defined(CONFIG_PM) && defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE)
|
41 |
| -#include <stm32_ll_exti.h> |
| 41 | +#include <stm32_ll_pwr.h> |
| 42 | +#include <zephyr/drivers/interrupt_controller/intc_exti_stm32.h> |
42 | 43 | #endif /* CONFIG_PM */
|
43 | 44 |
|
44 | 45 | #include <zephyr/linker/linker-defs.h>
|
@@ -121,6 +122,27 @@ static void uart_stm32_pm_policy_state_lock_get_unconditional(void)
|
121 | 122 | }
|
122 | 123 | }
|
123 | 124 |
|
| 125 | +#if defined(CONFIG_PM) && defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE) |
| 126 | +static void uart_stm32_pm_enable_wakeup_line(uint32_t wakeup_line) |
| 127 | +{ |
| 128 | +#if defined(CONFIG_SOC_SERIES_STM32WB0X) |
| 129 | + ARG_UNUSED(wakeup_line); |
| 130 | +#if defined(PWR_CR3_EIWL2) |
| 131 | + /** |
| 132 | + * If SoC is equipped with LPUART instance, |
| 133 | + * enable the associated wake-up line in PWRC. |
| 134 | + */ |
| 135 | + LL_PWR_EnableInternWU2(); |
| 136 | +#endif /* PWR_CR3_EIWL2 */ |
| 137 | +#else |
| 138 | + if (wakeup_line != STM32_WAKEUP_LINE_NONE) { |
| 139 | + /* Enable EXTI line associated to UART wake-up event */ |
| 140 | + stm32_exti_enable(wakeup_line, STM32_EXTI_TRIG_NONE, STM32_EXTI_MODE_IT); |
| 141 | + } |
| 142 | +#endif /* CONFIG_SOC_SERIES_STM32WB0X */ |
| 143 | +} |
| 144 | +#endif /* CONFIG_PM && IS_UART_WAKEUP_FROMSTOP_INSTANCE */ |
| 145 | + |
124 | 146 | static void uart_stm32_pm_policy_state_lock_get(const struct device *dev)
|
125 | 147 | {
|
126 | 148 | struct uart_stm32_data *data = dev->data;
|
@@ -2277,21 +2299,24 @@ static int uart_stm32_registers_configure(const struct device *dev)
|
2277 | 2299 | LL_USART_SetWKUPType(usart, LL_USART_WAKEUP_ON_RXNE);
|
2278 | 2300 | LL_USART_EnableIT_WKUP(usart);
|
2279 | 2301 | LL_USART_ClearFlag_WKUP(usart);
|
2280 |
| -#endif |
| 2302 | +#endif /* USART_CR3_WUFIE */ |
| 2303 | + |
| 2304 | +#if !defined(CONFIG_SOC_SERIES_STM32WB0X) || defined(USART_CR1_UESM) |
2281 | 2305 | LL_USART_EnableInStopMode(usart);
|
| 2306 | +#endif /* !CONFIG_SOC_SERIES_STM32WB0X || USART_CR1_UESM */ |
2282 | 2307 |
|
2283 |
| - if (config->wakeup_line != STM32_WAKEUP_LINE_NONE) { |
2284 |
| - /* Prepare the WAKEUP with the expected EXTI line */ |
2285 |
| - LL_EXTI_EnableIT_0_31(BIT(config->wakeup_line)); |
2286 |
| - } |
| 2308 | + /* Enable the wake-up line signal (if applicable to hardware) */ |
| 2309 | + uart_stm32_pm_enable_wakeup_line(config->wakeup_line); |
2287 | 2310 | }
|
| 2311 | + |
2288 | 2312 | #if defined(CONFIG_SOC_SERIES_STM32U5X) && DT_HAS_COMPAT_STATUS_OKAY(st_stm32_lpuart)
|
2289 | 2313 | if (config->wakeup_source) {
|
2290 | 2314 | /* Allow LPUART to operate in STOP modes. */
|
2291 | 2315 | LL_SRDAMR_GRP1_EnableAutonomousClock(LL_SRDAMR_GRP1_PERIPH_LPUART1AMEN);
|
2292 | 2316 | }
|
2293 |
| -#endif |
2294 |
| -#endif /* CONFIG_PM */ |
| 2317 | +#endif /* CONFIG_SOC_SERIES_STM32U5X && DT_HAS_COMPAT_STATUS_OKAY(st_stm32_lpuart) */ |
| 2318 | + |
| 2319 | +#endif /* CONFIG_PM && IS_UART_WAKEUP_FROMSTOP_INSTANCE */ |
2295 | 2320 |
|
2296 | 2321 | LL_USART_Enable(usart);
|
2297 | 2322 |
|
|
0 commit comments