From e89e4b529eb961f41e55e0fdeeee9217334bf6f7 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Wed, 3 Aug 2022 10:47:34 +0200 Subject: [PATCH] drivers: serial: stm32: Don't block PM if pinctrl sleep state is absent When dealing with pm action 'suspend', driver applies device pinctrl sleep state. Using PM_DEVICE modes should allow to save more current consumption, and applying pinctrl sleep state is one of the gains, but sleep state not being available on a device is not a sufficient reason to block PM transition to lower power mode. If this pin state is not provided for the device, warn but don't block pm transition. This will save some time to users setting up this feature for the first time. Warning will give the opportunity to users to fine tune their setup in a later step. Signed-off-by: Erwan Gouriou --- drivers/serial/uart_stm32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 2e77caa12e5..5de02fbee29 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1740,7 +1740,7 @@ static int uart_stm32_pm_action(const struct device *dev, break; case PM_DEVICE_ACTION_SUSPEND: uart_stm32_suspend_setup(dev); - /* Stop device clock */ + /* Stop device clock. Note: fixed clocks are not handled yet. */ err = clock_control_off(data->clock, (clock_control_subsys_t)&config->pclken[0]); if (err != 0) { LOG_ERR("Could not enable (LP)UART clock"); @@ -1749,7 +1749,10 @@ static int uart_stm32_pm_action(const struct device *dev, /* Move pins to sleep state */ err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); - if (err < 0) { + if (err == -ENOENT) { + /* Warn but don't block PM suspend */ + LOG_WRN("(LP)UART pinctrl sleep state not available "); + } else if (err < 0) { return err; } break;