Skip to content

Commit 67f80e3

Browse files
fabiobaltierikartben
authored andcommitted
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>
1 parent 581f756 commit 67f80e3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/i2c/i2c_ll_stm32_v2.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ int i2c_stm32_target_register(const struct device *dev,
437437
}
438438

439439
#if defined(CONFIG_PM_DEVICE_RUNTIME)
440+
/* Mark device as active */
441+
(void)pm_device_runtime_get(dev);
442+
440443
if (pm_device_wakeup_is_capable(dev)) {
441-
/* Mark device as active */
442-
(void)pm_device_runtime_get(dev);
443444
/* Enable wake-up from stop */
444445
LOG_DBG("i2c: enabling wakeup from stop");
445446
LL_I2C_EnableWakeUpFromStop(cfg->i2c);
@@ -532,9 +533,10 @@ int i2c_stm32_target_unregister(const struct device *dev,
532533
/* Disable wake-up from STOP */
533534
LOG_DBG("i2c: disabling wakeup from stop");
534535
LL_I2C_DisableWakeUpFromStop(i2c);
535-
/* Release the device */
536-
(void)pm_device_runtime_put(dev);
537536
}
537+
538+
/* Release the device */
539+
(void)pm_device_runtime_put(dev);
538540
#endif /* defined(CONFIG_PM_DEVICE_RUNTIME) */
539541

540542
data->slave_attached = false;

0 commit comments

Comments
 (0)