drivers: serial: stm32: add reinit after standby
When resuming from low power mode, if UART is disabled, this means that we come from a mode that reset the registers, so we redo a full init of the driver. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
This commit is contained in:
parent
be26c71fd4
commit
0792a85f77
1 changed files with 19 additions and 10 deletions
|
@ -2081,17 +2081,26 @@ static int uart_stm32_pm_action(const struct device *dev,
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PM_DEVICE_ACTION_RESUME:
|
case PM_DEVICE_ACTION_RESUME:
|
||||||
/* Set pins to active state */
|
/* When exiting low power mode, check whether UART is enabled.
|
||||||
err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
* If not, it means we are exiting Suspend to RAM mode (STM32
|
||||||
if (err < 0) {
|
* Standby), and the driver need to be reinitialized
|
||||||
return err;
|
*/
|
||||||
}
|
if (LL_USART_IsEnabled(config->usart)) {
|
||||||
|
/* Set pins to active state */
|
||||||
|
err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (err < 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/* enable clock */
|
/* enable clock */
|
||||||
err = clock_control_on(data->clock, (clock_control_subsys_t)&config->pclken[0]);
|
err = clock_control_on(data->clock,
|
||||||
if (err != 0) {
|
(clock_control_subsys_t)&config->pclken[0]);
|
||||||
LOG_ERR("Could not enable (LP)UART clock");
|
if (err != 0) {
|
||||||
return err;
|
LOG_ERR("Could not enable (LP)UART clock");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uart_stm32_init(dev);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_ACTION_SUSPEND:
|
case PM_DEVICE_ACTION_SUSPEND:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue