Skip to content

Commit 56a35e5

Browse files
gmarullnashif
authored andcommitted
pm: converge to suspend state for low power modes
The difference between low power and suspend states is a thin blur line that is is not clear and most drivers have used indistinctly. This patch converges to the usage of the suspend state for low power, since contrary to the low power state, it is used by both system and runtime device PM. The low power state is still kept, but its future is unclear and needs some discussion. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent c6cce80 commit 56a35e5

File tree

17 files changed

+20
-32
lines changed

17 files changed

+20
-32
lines changed

drivers/flash/spi_flash_at45.c

-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ static int spi_flash_at45_pm_control(const struct device *dev,
636636
release(dev);
637637
break;
638638

639-
case PM_DEVICE_STATE_LOW_POWER:
640639
case PM_DEVICE_STATE_SUSPEND:
641640
case PM_DEVICE_STATE_OFF:
642641
acquire(dev);

drivers/flash/spi_nor.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ LOG_MODULE_REGISTER(spi_nor, CONFIG_FLASH_LOG_LEVEL);
3838
*
3939
* When mapped to the Zephyr Device Power Management states:
4040
* * PM_DEVICE_STATE_ACTIVE covers both active and standby modes;
41-
* * PM_DEVICE_STATE_LOW_POWER, PM_DEVICE_STATE_SUSPEND, and
42-
* PM_DEVICE_STATE_OFF all correspond to deep-power-down mode.
41+
* * PM_DEVICE_STATE_SUSPEND, and PM_DEVICE_STATE_OFF all correspond
42+
* to deep-power-down mode.
4343
*/
4444

4545
#define SPI_NOR_MAX_ADDR_WIDTH 4

drivers/gpio/gpio_stm32.c

-2
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,6 @@ static int gpio_stm32_set_power_state(const struct device *dev,
583583
ret = gpio_stm32_clock_request(dev, true);
584584
} else if (state == PM_DEVICE_STATE_SUSPEND) {
585585
ret = gpio_stm32_clock_request(dev, false);
586-
} else if (state == PM_DEVICE_STATE_LOW_POWER) {
587-
ret = gpio_stm32_clock_request(dev, false);
588586
}
589587

590588
if (ret < 0) {

drivers/i2c/i2c_nrfx_twi.c

-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ static int twi_nrfx_pm_control(const struct device *dev,
230230
}
231231
break;
232232

233-
case PM_DEVICE_STATE_LOW_POWER:
234233
case PM_DEVICE_STATE_SUSPEND:
235234
case PM_DEVICE_STATE_OFF:
236235
nrfx_twi_uninit(&get_dev_config(dev)->twi);

drivers/i2c/i2c_nrfx_twim.c

-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ static int twim_nrfx_pm_control(const struct device *dev,
268268
}
269269
break;
270270

271-
case PM_DEVICE_STATE_LOW_POWER:
272271
case PM_DEVICE_STATE_SUSPEND:
273272
case PM_DEVICE_STATE_OFF:
274273
nrfx_twim_uninit(&get_dev_config(dev)->twim);

drivers/interrupt_controller/intc_ioapic.c

-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ static int ioapic_device_ctrl(const struct device *dev,
315315
int ret = 0;
316316

317317
switch (state) {
318-
case PM_DEVICE_STATE_LOW_POWER:
319-
break;
320318
case PM_DEVICE_STATE_ACTIVE:
321319
ret = ioapic_resume_from_suspend(dev);
322320
break;

drivers/modem/modem_receiver.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ int mdm_receiver_send(struct mdm_receiver_context *ctx,
198198
int mdm_receiver_sleep(struct mdm_receiver_context *ctx)
199199
{
200200
uart_irq_rx_disable(ctx->uart_dev);
201-
#ifdef PM_DEVICE_STATE_LOW_POWER
202-
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_LOW_POWER);
201+
#ifdef CONFIG_PM_DEVICE
202+
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_SUSPEND);
203203
#endif
204204
return 0;
205205
}
206206

207207
int mdm_receiver_wake(struct mdm_receiver_context *ctx)
208208
{
209-
#ifdef PM_DEVICE_STATE_LOW_POWER
209+
#ifdef CONFIG_PM_DEVICE
210210
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_ACTIVE);
211211
#endif
212212
uart_irq_rx_enable(ctx->uart_dev);

drivers/pwm/pwm_nrfx.c

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ static int pwm_nrfx_set_power_state(enum pm_device_state state,
301301
case PM_DEVICE_STATE_ACTIVE:
302302
err = pwm_nrfx_init(dev);
303303
break;
304-
case PM_DEVICE_STATE_LOW_POWER:
305304
case PM_DEVICE_STATE_SUSPEND:
306305
case PM_DEVICE_STATE_OFF:
307306
pwm_nrfx_uninit(dev);

drivers/sensor/fdc2x1x/fdc2x1x.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
506506
}
507507

508508
break;
509-
case PM_DEVICE_STATE_LOW_POWER:
509+
case PM_DEVICE_STATE_SUSPEND:
510510
if (curr_state == PM_DEVICE_STATE_OFF) {
511511
ret = fdc2x1x_set_shutdown(dev, false);
512512
if (ret) {
@@ -542,7 +542,6 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
542542

543543
switch (state) {
544544
case PM_DEVICE_STATE_ACTIVE:
545-
case PM_DEVICE_STATE_LOW_POWER:
546545
case PM_DEVICE_STATE_OFF:
547546
ret = fdc2x1x_set_pm_state(dev, state);
548547
break;

drivers/serial/uart_npcx.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
442442
enum pm_device_state next_state)
443443
{
444444
/* If next device power state is LOW or SUSPEND power state */
445-
if (next_state == PM_DEVICE_STATE_LOW_POWER ||
446-
next_state == PM_DEVICE_STATE_SUSPEND) {
445+
if (next_state == PM_DEVICE_STATE_SUSPEND) {
447446
/*
448447
* If uart device is busy with transmitting, the driver will
449448
* stay in while loop and wait for the transaction is completed.

drivers/spi/spi_nrfx_spi.c

-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ static int spi_nrfx_pm_control(const struct device *dev,
291291
data->ctx.config = NULL;
292292
break;
293293

294-
case PM_DEVICE_STATE_LOW_POWER:
295294
case PM_DEVICE_STATE_SUSPEND:
296295
case PM_DEVICE_STATE_OFF:
297296
nrfx_spi_uninit(&config->spi);

drivers/spi/spi_nrfx_spim.c

-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ static int spim_nrfx_pm_control(const struct device *dev,
338338
data->ctx.config = NULL;
339339
break;
340340

341-
case PM_DEVICE_STATE_LOW_POWER:
342341
case PM_DEVICE_STATE_SUSPEND:
343342
case PM_DEVICE_STATE_OFF:
344343
nrfx_spim_uninit(&config->spim);

samples/boards/nrf/system_off/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ void main(void)
6666
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
6767

6868
printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
69-
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER);
69+
rc = pm_device_state_set(cons, PM_DEVICE_STATE_SUSPEND);
7070
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
7171
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE);
7272

7373
printk("Sleep %u s\n", SLEEP_S);
7474
k_sleep(K_SECONDS(SLEEP_S));
7575

7676
printk("Sleep %u s with UART off\n", SLEEP_S);
77-
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER);
77+
rc = pm_device_state_set(cons, PM_DEVICE_STATE_SUSPEND);
7878
k_sleep(K_SECONDS(SLEEP_S));
7979
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE);
8080

samples/drivers/spi_flash_at45/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ void main(void)
150150
printk("OK\n");
151151

152152
#if IS_ENABLED(CONFIG_PM_DEVICE)
153-
printk("Putting the flash device into low power state... ");
154-
err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_LOW_POWER);
153+
printk("Putting the flash device into suspended state... ");
154+
err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_SUSPEND);
155155
if (err != 0) {
156156
printk("FAILED\n");
157157
return;

samples/sensor/apds9960/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void main(void)
7979
#ifdef CONFIG_PM_DEVICE
8080
enum pm_device_state p_state;
8181

82-
p_state = PM_DEVICE_STATE_LOW_POWER;
82+
p_state = PM_DEVICE_STATE_SUSPEND;
8383
pm_device_state_set(dev, p_state);
8484
printk("set low power state for 2s\n");
8585
k_sleep(K_MSEC(2000));

samples/sensor/fdc2x1x/src/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static void pm_info(enum pm_device_state state, int status)
4343
case PM_DEVICE_STATE_ACTIVE:
4444
printk("Enter ACTIVE_STATE ");
4545
break;
46-
case PM_DEVICE_STATE_LOW_POWER:
47-
printk("Enter LOW_POWER_STATE ");
46+
case PM_DEVICE_STATE_SUSPEND:
47+
printk("Enter SUSPEND_STATE ");
4848
break;
4949
case PM_DEVICE_STATE_OFF:
5050
printk("Enter OFF_STATE ");
@@ -95,7 +95,7 @@ void main(void)
9595
enum pm_device_state p_state;
9696
int ret;
9797

98-
p_state = PM_DEVICE_STATE_LOW_POWER;
98+
p_state = PM_DEVICE_STATE_SUSPEND;
9999
ret = pm_device_state_set(dev, p_state);
100100
pm_info(p_state, ret);
101101

tests/drivers/uart/uart_pm/src/main.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ static void test_uart_pm_in_idle(void)
148148
state_verify(dev, PM_DEVICE_STATE_ACTIVE);
149149
communication_verify(dev, true);
150150

151-
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
151+
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
152152
communication_verify(dev, false);
153153

154154
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
155155
communication_verify(dev, true);
156156

157-
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
157+
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
158158
communication_verify(dev, false);
159159

160160
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
@@ -171,7 +171,7 @@ static void test_uart_pm_poll_tx(void)
171171
communication_verify(dev, true);
172172

173173
uart_poll_out(dev, 'a');
174-
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
174+
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
175175

176176
communication_verify(dev, false);
177177

@@ -181,7 +181,7 @@ static void test_uart_pm_poll_tx(void)
181181

182182
/* Now same thing but with callback */
183183
uart_poll_out(dev, 'a');
184-
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
184+
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
185185

186186
communication_verify(dev, false);
187187

@@ -194,7 +194,7 @@ static void timeout(struct k_timer *timer)
194194
{
195195
const struct device *uart = k_timer_user_data_get(timer);
196196

197-
state_set(uart, PM_DEVICE_STATE_LOW_POWER, 0);
197+
state_set(uart, PM_DEVICE_STATE_SUSPEND, 0);
198198
}
199199

200200
static K_TIMER_DEFINE(pm_timer, timeout, NULL);

0 commit comments

Comments
 (0)