i2c: stm32: always call runtime_get when registering targets

Current code only calls pm_device_runtime_get when registering target
devices if the device is marked as wakeup capable by the application.

This does quite work for a setup with PM=n and PM_DEVICE=y and
PM_DEVICE_RUNTIME=y, where the CPU does not really go in stop mode ever,
and results in the i2c target device not working at all.

Fix this by always claiming the device when PM_DEVICE_RUNTIME is
enabled.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri
2025-06-23 12:00:48 +01:00
committed by Benjamin Cabé
parent 581f75656d
commit 67f80e35b8

View File

@@ -437,9 +437,10 @@ int i2c_stm32_target_register(const struct device *dev,
}
#if defined(CONFIG_PM_DEVICE_RUNTIME)
/* Mark device as active */
(void)pm_device_runtime_get(dev);
if (pm_device_wakeup_is_capable(dev)) {
/* Mark device as active */
(void)pm_device_runtime_get(dev);
/* Enable wake-up from stop */
LOG_DBG("i2c: enabling wakeup from stop");
LL_I2C_EnableWakeUpFromStop(cfg->i2c);
@@ -532,9 +533,10 @@ int i2c_stm32_target_unregister(const struct device *dev,
/* Disable wake-up from STOP */
LOG_DBG("i2c: disabling wakeup from stop");
LL_I2C_DisableWakeUpFromStop(i2c);
/* Release the device */
(void)pm_device_runtime_put(dev);
}
/* Release the device */
(void)pm_device_runtime_put(dev);
#endif /* defined(CONFIG_PM_DEVICE_RUNTIME) */
data->slave_attached = false;