pm: policy: Consider substates for state lock functions

Extend the current pm_policy_state_lock_*() functions to support
substates.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2022-04-07 13:06:12 +02:00 committed by Carles Cufí
commit 69b28bfd07
19 changed files with 145 additions and 55 deletions

View file

@ -101,7 +101,7 @@ static int entropy_cc13xx_cc26xx_get_entropy(const struct device *dev,
unsigned int key = irq_lock();
if (!data->constrained) {
pm_policy_state_lock_get(PM_STATE_STANDBY);
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
data->constrained = true;
}
irq_unlock(key);
@ -147,7 +147,8 @@ static void entropy_cc13xx_cc26xx_isr(const struct device *dev)
#ifdef CONFIG_PM
if (data->constrained) {
pm_policy_state_lock_put(
PM_STATE_STANDBY);
PM_STATE_STANDBY,
PM_ALL_SUBSTATES);
data->constrained = false;
}
#endif
@ -290,7 +291,7 @@ static int entropy_cc13xx_cc26xx_init(const struct device *dev)
#if defined(CONFIG_PM)
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
/* Stay out of standby until buffer is filled with entropy */
pm_policy_state_lock_get(PM_STATE_STANDBY);
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
data->constrained = true;
/* Register notification function */
Power_registerNotify(&data->post_notify,

View file

@ -246,7 +246,7 @@ static uint16_t rng_pool_get(struct rng_pool *rngp, uint8_t *buf, uint16_t len)
available = available - len;
if ((available <= rngp->threshold)
&& !LL_RNG_IsEnabledIT(entropy_stm32_rng_data.rng)) {
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
LL_RNG_EnableIT(entropy_stm32_rng_data.rng);
}
@ -300,7 +300,7 @@ static void stm32_rng_isr(const void *arg)
byte);
if (ret < 0) {
LL_RNG_DisableIT(entropy_stm32_rng_data.rng);
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
}
k_sem_give(&entropy_stm32_rng_data.sem_sync);
@ -512,7 +512,7 @@ static int entropy_stm32_rng_init(const struct device *dev)
* rng pool is being populated. The ISR will release the constraint again
* when the rng pool is filled.
*/
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
LL_RNG_EnableIT(dev_data->rng);