drivers: i2c: stm32: Support wakeup from STOP
This commit adds support for wakeup from STOP mode when the i2c device is configured as a target. Signed-off-by: Wouter Horré <wouter@versasense.com>
This commit is contained in:
parent
f2ddadf3a0
commit
3bc531e9c6
1 changed files with 22 additions and 0 deletions
|
@ -17,6 +17,8 @@
|
|||
#include <stm32_ll_i2c.h>
|
||||
#include <errno.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/pm/device.h>
|
||||
#include <zephyr/pm/device_runtime.h>
|
||||
#include "i2c_ll_stm32.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
|
||||
|
@ -227,6 +229,16 @@ int i2c_stm32_target_register(const struct device *dev,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_PM_DEVICE_RUNTIME)
|
||||
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);
|
||||
}
|
||||
#endif /* defined(CONFIG_PM_DEVICE_RUNTIME) */
|
||||
|
||||
LL_I2C_Enable(i2c);
|
||||
|
||||
if (!data->slave_cfg) {
|
||||
|
@ -306,6 +318,16 @@ int i2c_stm32_target_unregister(const struct device *dev,
|
|||
|
||||
LL_I2C_Disable(i2c);
|
||||
|
||||
#if defined(CONFIG_PM_DEVICE_RUNTIME)
|
||||
if (pm_device_wakeup_is_capable(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);
|
||||
}
|
||||
#endif /* defined(CONFIG_PM_DEVICE_RUNTIME) */
|
||||
|
||||
data->slave_attached = false;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue