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 <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
c6cce80ac4
commit
56a35e5682
17 changed files with 20 additions and 32 deletions
|
@ -636,7 +636,6 @@ static int spi_flash_at45_pm_control(const struct device *dev,
|
|||
release(dev);
|
||||
break;
|
||||
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
acquire(dev);
|
||||
|
|
|
@ -38,8 +38,8 @@ LOG_MODULE_REGISTER(spi_nor, CONFIG_FLASH_LOG_LEVEL);
|
|||
*
|
||||
* When mapped to the Zephyr Device Power Management states:
|
||||
* * PM_DEVICE_STATE_ACTIVE covers both active and standby modes;
|
||||
* * PM_DEVICE_STATE_LOW_POWER, PM_DEVICE_STATE_SUSPEND, and
|
||||
* PM_DEVICE_STATE_OFF all correspond to deep-power-down mode.
|
||||
* * PM_DEVICE_STATE_SUSPEND, and PM_DEVICE_STATE_OFF all correspond
|
||||
* to deep-power-down mode.
|
||||
*/
|
||||
|
||||
#define SPI_NOR_MAX_ADDR_WIDTH 4
|
||||
|
|
|
@ -583,8 +583,6 @@ static int gpio_stm32_set_power_state(const struct device *dev,
|
|||
ret = gpio_stm32_clock_request(dev, true);
|
||||
} else if (state == PM_DEVICE_STATE_SUSPEND) {
|
||||
ret = gpio_stm32_clock_request(dev, false);
|
||||
} else if (state == PM_DEVICE_STATE_LOW_POWER) {
|
||||
ret = gpio_stm32_clock_request(dev, false);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -230,7 +230,6 @@ static int twi_nrfx_pm_control(const struct device *dev,
|
|||
}
|
||||
break;
|
||||
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
nrfx_twi_uninit(&get_dev_config(dev)->twi);
|
||||
|
|
|
@ -268,7 +268,6 @@ static int twim_nrfx_pm_control(const struct device *dev,
|
|||
}
|
||||
break;
|
||||
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
nrfx_twim_uninit(&get_dev_config(dev)->twim);
|
||||
|
|
|
@ -315,8 +315,6 @@ static int ioapic_device_ctrl(const struct device *dev,
|
|||
int ret = 0;
|
||||
|
||||
switch (state) {
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
break;
|
||||
case PM_DEVICE_STATE_ACTIVE:
|
||||
ret = ioapic_resume_from_suspend(dev);
|
||||
break;
|
||||
|
|
|
@ -198,15 +198,15 @@ int mdm_receiver_send(struct mdm_receiver_context *ctx,
|
|||
int mdm_receiver_sleep(struct mdm_receiver_context *ctx)
|
||||
{
|
||||
uart_irq_rx_disable(ctx->uart_dev);
|
||||
#ifdef PM_DEVICE_STATE_LOW_POWER
|
||||
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_LOW_POWER);
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_SUSPEND);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mdm_receiver_wake(struct mdm_receiver_context *ctx)
|
||||
{
|
||||
#ifdef PM_DEVICE_STATE_LOW_POWER
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_ACTIVE);
|
||||
#endif
|
||||
uart_irq_rx_enable(ctx->uart_dev);
|
||||
|
|
|
@ -301,7 +301,6 @@ static int pwm_nrfx_set_power_state(enum pm_device_state state,
|
|||
case PM_DEVICE_STATE_ACTIVE:
|
||||
err = pwm_nrfx_init(dev);
|
||||
break;
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
pwm_nrfx_uninit(dev);
|
||||
|
|
|
@ -506,7 +506,7 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
|
|||
}
|
||||
|
||||
break;
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
if (curr_state == PM_DEVICE_STATE_OFF) {
|
||||
ret = fdc2x1x_set_shutdown(dev, false);
|
||||
if (ret) {
|
||||
|
@ -542,7 +542,6 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
|
|||
|
||||
switch (state) {
|
||||
case PM_DEVICE_STATE_ACTIVE:
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
ret = fdc2x1x_set_pm_state(dev, state);
|
||||
break;
|
||||
|
|
|
@ -442,8 +442,7 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
|
|||
enum pm_device_state next_state)
|
||||
{
|
||||
/* If next device power state is LOW or SUSPEND power state */
|
||||
if (next_state == PM_DEVICE_STATE_LOW_POWER ||
|
||||
next_state == PM_DEVICE_STATE_SUSPEND) {
|
||||
if (next_state == PM_DEVICE_STATE_SUSPEND) {
|
||||
/*
|
||||
* If uart device is busy with transmitting, the driver will
|
||||
* stay in while loop and wait for the transaction is completed.
|
||||
|
|
|
@ -291,7 +291,6 @@ static int spi_nrfx_pm_control(const struct device *dev,
|
|||
data->ctx.config = NULL;
|
||||
break;
|
||||
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
nrfx_spi_uninit(&config->spi);
|
||||
|
|
|
@ -338,7 +338,6 @@ static int spim_nrfx_pm_control(const struct device *dev,
|
|||
data->ctx.config = NULL;
|
||||
break;
|
||||
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
nrfx_spim_uninit(&config->spim);
|
||||
|
|
|
@ -66,7 +66,7 @@ void main(void)
|
|||
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
|
||||
|
||||
printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
|
||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER);
|
||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_SUSPEND);
|
||||
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
|
||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE);
|
||||
|
||||
|
@ -74,7 +74,7 @@ void main(void)
|
|||
k_sleep(K_SECONDS(SLEEP_S));
|
||||
|
||||
printk("Sleep %u s with UART off\n", SLEEP_S);
|
||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER);
|
||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_SUSPEND);
|
||||
k_sleep(K_SECONDS(SLEEP_S));
|
||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE);
|
||||
|
||||
|
|
|
@ -150,8 +150,8 @@ void main(void)
|
|||
printk("OK\n");
|
||||
|
||||
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
||||
printk("Putting the flash device into low power state... ");
|
||||
err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_LOW_POWER);
|
||||
printk("Putting the flash device into suspended state... ");
|
||||
err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_SUSPEND);
|
||||
if (err != 0) {
|
||||
printk("FAILED\n");
|
||||
return;
|
||||
|
|
|
@ -79,7 +79,7 @@ void main(void)
|
|||
#ifdef CONFIG_PM_DEVICE
|
||||
enum pm_device_state p_state;
|
||||
|
||||
p_state = PM_DEVICE_STATE_LOW_POWER;
|
||||
p_state = PM_DEVICE_STATE_SUSPEND;
|
||||
pm_device_state_set(dev, p_state);
|
||||
printk("set low power state for 2s\n");
|
||||
k_sleep(K_MSEC(2000));
|
||||
|
|
|
@ -43,8 +43,8 @@ static void pm_info(enum pm_device_state state, int status)
|
|||
case PM_DEVICE_STATE_ACTIVE:
|
||||
printk("Enter ACTIVE_STATE ");
|
||||
break;
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
printk("Enter LOW_POWER_STATE ");
|
||||
case PM_DEVICE_STATE_SUSPEND:
|
||||
printk("Enter SUSPEND_STATE ");
|
||||
break;
|
||||
case PM_DEVICE_STATE_OFF:
|
||||
printk("Enter OFF_STATE ");
|
||||
|
@ -95,7 +95,7 @@ void main(void)
|
|||
enum pm_device_state p_state;
|
||||
int ret;
|
||||
|
||||
p_state = PM_DEVICE_STATE_LOW_POWER;
|
||||
p_state = PM_DEVICE_STATE_SUSPEND;
|
||||
ret = pm_device_state_set(dev, p_state);
|
||||
pm_info(p_state, ret);
|
||||
|
||||
|
|
|
@ -148,13 +148,13 @@ static void test_uart_pm_in_idle(void)
|
|||
state_verify(dev, PM_DEVICE_STATE_ACTIVE);
|
||||
communication_verify(dev, true);
|
||||
|
||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
|
||||
communication_verify(dev, false);
|
||||
|
||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||
communication_verify(dev, true);
|
||||
|
||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
|
||||
communication_verify(dev, false);
|
||||
|
||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||
|
@ -171,7 +171,7 @@ static void test_uart_pm_poll_tx(void)
|
|||
communication_verify(dev, true);
|
||||
|
||||
uart_poll_out(dev, 'a');
|
||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
|
||||
|
||||
communication_verify(dev, false);
|
||||
|
||||
|
@ -181,7 +181,7 @@ static void test_uart_pm_poll_tx(void)
|
|||
|
||||
/* Now same thing but with callback */
|
||||
uart_poll_out(dev, 'a');
|
||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||
state_set(dev, PM_DEVICE_STATE_SUSPEND, 0);
|
||||
|
||||
communication_verify(dev, false);
|
||||
|
||||
|
@ -194,7 +194,7 @@ static void timeout(struct k_timer *timer)
|
|||
{
|
||||
const struct device *uart = k_timer_user_data_get(timer);
|
||||
|
||||
state_set(uart, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||
state_set(uart, PM_DEVICE_STATE_SUSPEND, 0);
|
||||
}
|
||||
|
||||
static K_TIMER_DEFINE(pm_timer, timeout, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue