@@ -2224,13 +2224,13 @@ static int uart_stm32_registers_configure(const struct device *dev)
2224
2224
/* Wait until TEACK flag is set */
2225
2225
while (!(LL_USART_IsActiveFlag_TEACK (usart ))) {
2226
2226
}
2227
- #endif /* ! USART_ISR_TEACK */
2227
+ #endif /* USART_ISR_TEACK */
2228
2228
2229
2229
#ifdef USART_ISR_REACK
2230
2230
/* Wait until REACK flag is set */
2231
2231
while (!(LL_USART_IsActiveFlag_REACK (usart ))) {
2232
2232
}
2233
- #endif /* ! USART_ISR_REACK */
2233
+ #endif /* USART_ISR_REACK */
2234
2234
2235
2235
return 0 ;
2236
2236
}
@@ -2301,14 +2301,12 @@ static void uart_stm32_suspend_setup(const struct device *dev)
2301
2301
LL_USART_ClearFlag_ORE (usart );
2302
2302
}
2303
2303
2304
- static int uart_stm32_pm_action (const struct device * dev ,
2305
- enum pm_device_action action )
2304
+ static int uart_stm32_pm_action (const struct device * dev , enum pm_device_action action )
2306
2305
{
2307
2306
const struct uart_stm32_config * config = dev -> config ;
2308
2307
struct uart_stm32_data * data = dev -> data ;
2309
2308
int err ;
2310
2309
2311
-
2312
2310
switch (action ) {
2313
2311
case PM_DEVICE_ACTION_RESUME :
2314
2312
/* Set pins to active state */
@@ -2317,21 +2315,34 @@ static int uart_stm32_pm_action(const struct device *dev,
2317
2315
return err ;
2318
2316
}
2319
2317
2320
- /* Enable clock */
2321
- err = clock_control_on (data -> clock ,
2322
- (clock_control_subsys_t )& config -> pclken [0 ]);
2318
+ /* Enable bus clock */
2319
+ err = clock_control_on (data -> clock , (clock_control_subsys_t )& config -> pclken [0 ]);
2323
2320
if (err < 0 ) {
2324
2321
LOG_ERR ("Could not enable (LP)UART clock" );
2325
2322
return err ;
2326
2323
}
2327
2324
2328
- if ((IS_ENABLED (CONFIG_PM_S2RAM )) &&
2329
- (!LL_USART_IsEnabled (config -> usart ))) {
2325
+ if (!LL_USART_IsEnabled (config -> usart )) {
2330
2326
/* When exiting low power mode, check whether UART is enabled.
2331
- * If not, it means we are exiting Suspend to RAM mode (STM32
2332
- * Standby), and the driver needs to be reinitialized.
2327
+ * If not, it means the peripheral has been powered down
2328
+ * by the low-power mode. If suspend-to-RAM is enabled,
2329
+ * assume the entire SoC has been powered down and do a
2330
+ * full re-initialization. Otherwise, assume that the
2331
+ * low-power mode shut down power to the UART but not
2332
+ * critical peripherals (CPU, GPIO, RCC), which means
2333
+ * we only have to reconfigure this UART instance.
2334
+ *
2335
+ * STOP2 on STM32WLE5 is an example of such low-power mode.
2333
2336
*/
2334
- uart_stm32_init (dev );
2337
+ if (IS_ENABLED (CONFIG_PM_S2RAM )) {
2338
+ err = uart_stm32_init (dev );
2339
+ } else {
2340
+ err = uart_stm32_registers_configure (dev );
2341
+ }
2342
+
2343
+ if (err < 0 ) {
2344
+ return err ;
2345
+ }
2335
2346
}
2336
2347
break ;
2337
2348
case PM_DEVICE_ACTION_SUSPEND :
0 commit comments