Skip to content

Commit 69b28bf

Browse files
carlocaionecarlescufi
authored andcommitted
pm: policy: Consider substates for state lock functions
Extend the current pm_policy_state_lock_*() functions to support substates. Signed-off-by: Carlo Caione <[email protected]>
1 parent 619fce9 commit 69b28bf

File tree

19 files changed

+145
-55
lines changed

19 files changed

+145
-55
lines changed

boards/arm/cc1352r1_launchxl/doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ disable sleep state 2 while polling:
216216

217217
.. code-block:: c
218218
219-
pm_policy_state_lock_get(PM_STATE_STANDBY);
219+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
220220
<code that calls uart_poll_in() and expects input at any point in time>
221-
pm_policy_state_lock_put(PM_STATE_STANDBY);
221+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
222222
223223
224224
References

boards/arm/cc1352r_sensortag/doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ disable sleep state 2 while polling:
242242

243243
.. code-block:: c
244244
245-
pm_policy_state_lock_get(PM_STATE_STANDBY);
245+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
246246
<code that calls uart_poll_in() and expects input at any point in time>
247-
pm_policy_state_lock_put(PM_STATE_STANDBY);
247+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
248248
249249
250250
References

boards/arm/cc26x2r1_launchxl/doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ disable sleep state 2 while polling:
222222

223223
.. code-block:: c
224224
225-
pm_policy_state_lock_get(PM_STATE_STANDBY);
225+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
226226
<code that calls uart_poll_in() and expects input at any point in time>
227-
pm_policy_state_lock_put(PM_STATE_STANDBY);
227+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
228228
229229
230230
References

drivers/entropy/entropy_cc13xx_cc26xx.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int entropy_cc13xx_cc26xx_get_entropy(const struct device *dev,
101101
unsigned int key = irq_lock();
102102

103103
if (!data->constrained) {
104-
pm_policy_state_lock_get(PM_STATE_STANDBY);
104+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
105105
data->constrained = true;
106106
}
107107
irq_unlock(key);
@@ -147,7 +147,8 @@ static void entropy_cc13xx_cc26xx_isr(const struct device *dev)
147147
#ifdef CONFIG_PM
148148
if (data->constrained) {
149149
pm_policy_state_lock_put(
150-
PM_STATE_STANDBY);
150+
PM_STATE_STANDBY,
151+
PM_ALL_SUBSTATES);
151152
data->constrained = false;
152153
}
153154
#endif
@@ -290,7 +291,7 @@ static int entropy_cc13xx_cc26xx_init(const struct device *dev)
290291
#if defined(CONFIG_PM)
291292
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
292293
/* Stay out of standby until buffer is filled with entropy */
293-
pm_policy_state_lock_get(PM_STATE_STANDBY);
294+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
294295
data->constrained = true;
295296
/* Register notification function */
296297
Power_registerNotify(&data->post_notify,

drivers/entropy/entropy_stm32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static uint16_t rng_pool_get(struct rng_pool *rngp, uint8_t *buf, uint16_t len)
246246
available = available - len;
247247
if ((available <= rngp->threshold)
248248
&& !LL_RNG_IsEnabledIT(entropy_stm32_rng_data.rng)) {
249-
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
249+
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
250250
LL_RNG_EnableIT(entropy_stm32_rng_data.rng);
251251
}
252252

@@ -300,7 +300,7 @@ static void stm32_rng_isr(const void *arg)
300300
byte);
301301
if (ret < 0) {
302302
LL_RNG_DisableIT(entropy_stm32_rng_data.rng);
303-
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
303+
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
304304
}
305305

306306
k_sem_give(&entropy_stm32_rng_data.sem_sync);
@@ -512,7 +512,7 @@ static int entropy_stm32_rng_init(const struct device *dev)
512512
* rng pool is being populated. The ISR will release the constraint again
513513
* when the rng pool is filled.
514514
*/
515-
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
515+
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
516516

517517
LL_RNG_EnableIT(dev_data->rng);
518518

drivers/i2c/i2c_cc13xx_cc26xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int i2c_cc13xx_cc26xx_transfer(const struct device *dev,
196196

197197
k_sem_take(&data->lock, K_FOREVER);
198198

199-
pm_policy_state_lock_get(PM_STATE_STANDBY);
199+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
200200

201201
for (int i = 0; i < num_msgs; i++) {
202202
/* Not supported by hardware */
@@ -218,7 +218,7 @@ static int i2c_cc13xx_cc26xx_transfer(const struct device *dev,
218218
}
219219
}
220220

221-
pm_policy_state_lock_put(PM_STATE_STANDBY);
221+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
222222

223223
k_sem_give(&data->lock);
224224

drivers/serial/uart_cc13xx_cc26xx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static void uart_cc13xx_cc26xx_irq_tx_enable(const struct device *dev)
250250
* standby mode instead, since it is the power state that
251251
* would interfere with a transfer.
252252
*/
253-
pm_policy_state_lock_get(PM_STATE_STANDBY);
253+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
254254
data->tx_constrained = true;
255255
}
256256
#endif
@@ -268,7 +268,7 @@ static void uart_cc13xx_cc26xx_irq_tx_disable(const struct device *dev)
268268
struct uart_cc13xx_cc26xx_data *data = dev->data;
269269

270270
if (data->tx_constrained) {
271-
pm_policy_state_lock_put(PM_STATE_STANDBY);
271+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
272272
data->tx_constrained = false;
273273
}
274274
#endif
@@ -294,7 +294,7 @@ static void uart_cc13xx_cc26xx_irq_rx_enable(const struct device *dev)
294294
* standby.
295295
*/
296296
if (!data->rx_constrained) {
297-
pm_policy_state_lock_get(PM_STATE_STANDBY);
297+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
298298
data->rx_constrained = true;
299299
}
300300
#endif
@@ -310,7 +310,7 @@ static void uart_cc13xx_cc26xx_irq_rx_disable(const struct device *dev)
310310
struct uart_cc13xx_cc26xx_data *data = dev->data;
311311

312312
if (data->rx_constrained) {
313-
pm_policy_state_lock_put(PM_STATE_STANDBY);
313+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
314314
data->rx_constrained = false;
315315
}
316316
#endif

drivers/serial/uart_ite_it8xxx2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void uart1_wui_isr(const struct device *gpio, struct gpio_callback *cb,
5656
* The pm state of it8xxx2 chip only supports standby, so here we
5757
* can directly set the constraint for standby.
5858
*/
59-
pm_policy_state_lock_get(PM_STATE_STANDBY);
59+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
6060
k_work_reschedule(&uart_console_data->rx_refresh_timeout_work, delay);
6161
#endif
6262
}
@@ -76,7 +76,7 @@ void uart2_wui_isr(const struct device *gpio, struct gpio_callback *cb,
7676
* The pm state of it8xxx2 chip only supports standby, so here we
7777
* can directly set the constraint for standby.
7878
*/
79-
pm_policy_state_lock_get(PM_STATE_STANDBY);
79+
pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
8080
k_work_reschedule(&uart_console_data->rx_refresh_timeout_work, delay);
8181
#endif
8282
}
@@ -116,7 +116,7 @@ static void uart_it8xxx2_rx_refresh_timeout(struct k_work *work)
116116
{
117117
ARG_UNUSED(work);
118118

119-
pm_policy_state_lock_put(PM_STATE_STANDBY);
119+
pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES);
120120
}
121121
#endif
122122
#endif /* CONFIG_PM_DEVICE */

drivers/serial/uart_mcux_lpuart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static void mcux_lpuart_pm_policy_state_lock_get(const struct device *dev)
105105

106106
if (!data->pm_state_lock_on) {
107107
data->pm_state_lock_on = true;
108-
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
108+
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
109109
}
110110
}
111111

@@ -115,7 +115,7 @@ static void mcux_lpuart_pm_policy_state_lock_put(const struct device *dev)
115115

116116
if (data->pm_state_lock_on) {
117117
data->pm_state_lock_on = false;
118-
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
118+
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
119119
}
120120
}
121121
#endif /* CONFIG_PM */

drivers/serial/uart_npcx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ static void uart_npcx_pm_policy_state_lock_get(struct uart_npcx_data *data,
6464
enum uart_pm_policy_state_flag flag)
6565
{
6666
if (atomic_test_and_set_bit(data->pm_policy_state_flag, flag) == 0) {
67-
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE);
67+
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
6868
}
6969
}
7070

7171
static void uart_npcx_pm_policy_state_lock_put(struct uart_npcx_data *data,
7272
enum uart_pm_policy_state_flag flag)
7373
{
7474
if (atomic_test_and_clear_bit(data->pm_policy_state_flag, flag) == 1) {
75-
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE);
75+
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
7676
}
7777
}
7878
#endif /* defined(CONFIG_PM) && defined(CONFIG_UART_INTERRUPT_DRIVEN) */

0 commit comments

Comments
 (0)