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:
parent
619fce9e0f
commit
69b28bfd07
19 changed files with 145 additions and 55 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ static int i2c_cc13xx_cc26xx_transfer(const struct device *dev,
|
|||
|
||||
k_sem_take(&data->lock, K_FOREVER);
|
||||
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
|
||||
for (int i = 0; i < num_msgs; i++) {
|
||||
/* Not supported by hardware */
|
||||
|
@ -218,7 +218,7 @@ static int i2c_cc13xx_cc26xx_transfer(const struct device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
|
||||
k_sem_give(&data->lock);
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ static void uart_cc13xx_cc26xx_irq_tx_enable(const struct device *dev)
|
|||
* standby mode instead, since it is the power state that
|
||||
* would interfere with a transfer.
|
||||
*/
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
data->tx_constrained = true;
|
||||
}
|
||||
#endif
|
||||
|
@ -268,7 +268,7 @@ static void uart_cc13xx_cc26xx_irq_tx_disable(const struct device *dev)
|
|||
struct uart_cc13xx_cc26xx_data *data = dev->data;
|
||||
|
||||
if (data->tx_constrained) {
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
data->tx_constrained = false;
|
||||
}
|
||||
#endif
|
||||
|
@ -294,7 +294,7 @@ static void uart_cc13xx_cc26xx_irq_rx_enable(const struct device *dev)
|
|||
* standby.
|
||||
*/
|
||||
if (!data->rx_constrained) {
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
data->rx_constrained = true;
|
||||
}
|
||||
#endif
|
||||
|
@ -310,7 +310,7 @@ static void uart_cc13xx_cc26xx_irq_rx_disable(const struct device *dev)
|
|||
struct uart_cc13xx_cc26xx_data *data = dev->data;
|
||||
|
||||
if (data->rx_constrained) {
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
data->rx_constrained = false;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -56,7 +56,7 @@ void uart1_wui_isr(const struct device *gpio, struct gpio_callback *cb,
|
|||
* The pm state of it8xxx2 chip only supports standby, so here we
|
||||
* can directly set the constraint for standby.
|
||||
*/
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
k_work_reschedule(&uart_console_data->rx_refresh_timeout_work, delay);
|
||||
#endif
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void uart2_wui_isr(const struct device *gpio, struct gpio_callback *cb,
|
|||
* The pm state of it8xxx2 chip only supports standby, so here we
|
||||
* can directly set the constraint for standby.
|
||||
*/
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
k_work_reschedule(&uart_console_data->rx_refresh_timeout_work, delay);
|
||||
#endif
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ static void uart_it8xxx2_rx_refresh_timeout(struct k_work *work)
|
|||
{
|
||||
ARG_UNUSED(work);
|
||||
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_PM_DEVICE */
|
||||
|
|
|
@ -105,7 +105,7 @@ static void mcux_lpuart_pm_policy_state_lock_get(const struct device *dev)
|
|||
|
||||
if (!data->pm_state_lock_on) {
|
||||
data->pm_state_lock_on = true;
|
||||
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
|
||||
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ static void mcux_lpuart_pm_policy_state_lock_put(const struct device *dev)
|
|||
|
||||
if (data->pm_state_lock_on) {
|
||||
data->pm_state_lock_on = false;
|
||||
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
|
||||
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
|
|
@ -64,7 +64,7 @@ static void uart_npcx_pm_policy_state_lock_get(struct uart_npcx_data *data,
|
|||
enum uart_pm_policy_state_flag flag)
|
||||
{
|
||||
if (atomic_test_and_set_bit(data->pm_policy_state_flag, flag) == 0) {
|
||||
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
|
||||
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ static void uart_npcx_pm_policy_state_lock_put(struct uart_npcx_data *data,
|
|||
enum uart_pm_policy_state_flag flag)
|
||||
{
|
||||
if (atomic_test_and_clear_bit(data->pm_policy_state_flag, flag) == 1) {
|
||||
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
|
||||
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
#endif /* defined(CONFIG_PM) && defined(CONFIG_UART_INTERRUPT_DRIVEN) */
|
||||
|
|
|
@ -681,7 +681,7 @@ static void uart_ns16550_irq_tx_enable(const struct device *dev)
|
|||
* different states.
|
||||
*/
|
||||
for (uint8_t i = 0U; i < num_cpu_states; i++) {
|
||||
pm_policy_state_lock_get(cpu_states[i].state);
|
||||
pm_policy_state_lock_get(cpu_states[i].state, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -718,7 +718,7 @@ static void uart_ns16550_irq_tx_disable(const struct device *dev)
|
|||
* to different states.
|
||||
*/
|
||||
for (uint8_t i = 0U; i < num_cpu_states; i++) {
|
||||
pm_policy_state_lock_put(cpu_states[i].state);
|
||||
pm_policy_state_lock_put(cpu_states[i].state, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -78,7 +78,7 @@ static void uart_stm32_pm_policy_state_lock_get(const struct device *dev)
|
|||
|
||||
if (!data->pm_policy_state_on) {
|
||||
data->pm_policy_state_on = true;
|
||||
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
|
||||
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ static void uart_stm32_pm_policy_state_lock_put(const struct device *dev)
|
|||
|
||||
if (data->pm_policy_state_on) {
|
||||
data->pm_policy_state_on = false;
|
||||
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
|
||||
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
|
|
@ -141,7 +141,7 @@ static int spi_cc13xx_cc26xx_transceive(const struct device *dev,
|
|||
int err;
|
||||
|
||||
spi_context_lock(ctx, false, NULL, config);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
|
||||
err = spi_cc13xx_cc26xx_configure(dev, config);
|
||||
if (err) {
|
||||
|
@ -175,7 +175,7 @@ static int spi_cc13xx_cc26xx_transceive(const struct device *dev,
|
|||
spi_context_cs_control(ctx, false);
|
||||
|
||||
done:
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY);
|
||||
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
|
||||
spi_context_release(ctx, err);
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue