pm: device: Align state names with system states

Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-05-07 14:18:57 -07:00 committed by Anas Nashif
commit 0c607adb63
51 changed files with 258 additions and 258 deletions

View file

@ -215,20 +215,20 @@ registers, clocks, memory etc.
The four device power states: The four device power states:
:code:`PM_DEVICE_ACTIVE_STATE` :code:`PM_DEVICE_STATE_ACTIVE`
Normal operation of the device. All device context is retained. Normal operation of the device. All device context is retained.
:code:`PM_DEVICE_LOW_POWER_STATE` :code:`PM_DEVICE_STATE_LOW_POWER`
Device context is preserved by the HW and need not be restored by the driver. Device context is preserved by the HW and need not be restored by the driver.
:code:`PM_DEVICE_SUSPEND_STATE` :code:`PM_DEVICE_STATE_SUSPEND`
Most device context is lost by the hardware. Device drivers must save and Most device context is lost by the hardware. Device drivers must save and
restore or reinitialize any context lost by the hardware. restore or reinitialize any context lost by the hardware.
:code:`PM_DEVICE_OFF_STATE` :code:`PM_DEVICE_STATE_OFF`
Power has been fully removed from the device. The device context is lost Power has been fully removed from the device. The device context is lost
when this state is entered. Need to reinitialize the device when powering when this state is entered. Need to reinitialize the device when powering

View file

@ -476,7 +476,7 @@ static int st7735r_init(const struct device *dev)
} }
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
data->cmd_data_dev = device_get_binding(config->cmd_data.name); data->cmd_data_dev = device_get_binding(config->cmd_data.name);
@ -527,18 +527,18 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
switch (ctrl_command) { switch (ctrl_command) {
case PM_DEVICE_STATE_SET: case PM_DEVICE_STATE_SET:
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_STATE_ACTIVE) {
ret = st7735r_exit_sleep(data); ret = st7735r_exit_sleep(data);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
} else { } else {
ret = st7735r_enter_sleep(data); ret = st7735r_enter_sleep(data);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
data->pm_state = PM_DEVICE_LOW_POWER_STATE; data->pm_state = PM_DEVICE_STATE_LOW_POWER;
} }
break; break;

View file

@ -376,7 +376,7 @@ static int st7789v_init(const struct device *dev)
#endif #endif
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
data->cmd_data_gpio = device_get_binding( data->cmd_data_gpio = device_get_binding(
@ -416,13 +416,13 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case DEVICE_PM_SET_POWER_STATE:
if (*state == PM_DEVICE_ACTIVE_STATE) { if (*state == PM_DEVICE_STATE_ACTIVE) {
st7789v_exit_sleep(data); st7789v_exit_sleep(data);
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
ret = 0; ret = 0;
} else { } else {
st7789v_enter_sleep(data); st7789v_enter_sleep(data);
data->pm_state = PM_DEVICE_LOW_POWER_STATE; data->pm_state = PM_DEVICE_STATE_LOW_POWER;
ret = 0; ret = 0;
} }
break; break;

View file

@ -272,16 +272,16 @@ static int entropy_cc13xx_cc26xx_set_power_state(const struct device *dev,
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
int ret = 0; int ret = 0;
if ((new_state == PM_DEVICE_ACTIVE_STATE) && if ((new_state == PM_DEVICE_STATE_ACTIVE) &&
(new_state != data->pm_state)) { (new_state != data->pm_state)) {
Power_setDependency(PowerCC26XX_PERIPH_TRNG); Power_setDependency(PowerCC26XX_PERIPH_TRNG);
start_trng(data); start_trng(data);
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
if (data->pm_state == PM_DEVICE_ACTIVE_STATE) { if (data->pm_state == PM_DEVICE_STATE_ACTIVE) {
stop_trng(data); stop_trng(data);
Power_releaseDependency(PowerCC26XX_PERIPH_TRNG); Power_releaseDependency(PowerCC26XX_PERIPH_TRNG);
} }
@ -324,7 +324,7 @@ static int entropy_cc13xx_cc26xx_init(const struct device *dev)
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
/* Initialize driver data */ /* Initialize driver data */

View file

@ -200,7 +200,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
} }
if (command == PM_DEVICE_STATE_SET) { if (command == PM_DEVICE_STATE_SET) {
if (*state == PM_DEVICE_SUSPEND_STATE) { if (*state == PM_DEVICE_STATE_SUSPEND) {
LOG_DBG("Suspending"); LOG_DBG("Suspending");
ret = net_if_suspend(eth_ctx->iface); ret = net_if_suspend(eth_ctx->iface);
@ -215,7 +215,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
ENET_Deinit(eth_ctx->base); ENET_Deinit(eth_ctx->base);
clock_control_off(eth_ctx->clock_dev, clock_control_off(eth_ctx->clock_dev,
(clock_control_subsys_t)eth_ctx->clock); (clock_control_subsys_t)eth_ctx->clock);
} else if (*state == PM_DEVICE_ACTIVE_STATE) { } else if (*state == PM_DEVICE_STATE_ACTIVE) {
LOG_DBG("Resuming"); LOG_DBG("Resuming");
clock_control_on(eth_ctx->clock_dev, clock_control_on(eth_ctx->clock_dev,

View file

@ -641,16 +641,16 @@ static int spi_flash_at45_pm_control(const struct device *dev,
if (new_state != dev_data->pm_state) { if (new_state != dev_data->pm_state) {
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
acquire(dev); acquire(dev);
power_down_op(dev, CMD_EXIT_DPD, power_down_op(dev, CMD_EXIT_DPD,
dev_config->t_exit_dpd); dev_config->t_exit_dpd);
release(dev); release(dev);
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
acquire(dev); acquire(dev);
power_down_op(dev, power_down_op(dev,
dev_config->use_udpd ? CMD_ENTER_UDPD dev_config->use_udpd ? CMD_ENTER_UDPD
@ -721,7 +721,7 @@ static const struct flash_driver_api spi_flash_at45_api = {
static struct spi_flash_at45_data inst_##idx##_data = { \ static struct spi_flash_at45_data inst_##idx##_data = { \
.lock = Z_SEM_INITIALIZER(inst_##idx##_data.lock, 1, 1), \ .lock = Z_SEM_INITIALIZER(inst_##idx##_data.lock, 1, 1), \
IF_ENABLED(CONFIG_PM_DEVICE, ( \ IF_ENABLED(CONFIG_PM_DEVICE, ( \
.pm_state = PM_DEVICE_ACTIVE_STATE)) \ .pm_state = PM_DEVICE_STATE_ACTIVE)) \
}; \ }; \
INST_RESET_GPIO_SPEC(idx) \ INST_RESET_GPIO_SPEC(idx) \
INST_WP_GPIO_SPEC(idx) \ INST_WP_GPIO_SPEC(idx) \

View file

@ -37,9 +37,9 @@ LOG_MODULE_REGISTER(spi_nor, CONFIG_FLASH_LOG_LEVEL);
* Kconfig option. * Kconfig option.
* *
* When mapped to the Zephyr Device Power Management states: * When mapped to the Zephyr Device Power Management states:
* * PM_DEVICE_ACTIVE_STATE covers both active and standby modes; * * PM_DEVICE_STATE_ACTIVE covers both active and standby modes;
* * PM_DEVICE_LOW_POWER_STATE, PM_DEVICE_SUSPEND_STATE, and * * PM_DEVICE_STATE_LOW_POWER, PM_DEVICE_STATE_SUSPEND, and
* PM_DEVICE_OFF_STATE all correspond to deep-power-down mode. * PM_DEVICE_STATE_OFF all correspond to deep-power-down mode.
*/ */
#define SPI_NOR_MAX_ADDR_WIDTH 4 #define SPI_NOR_MAX_ADDR_WIDTH 4

View file

@ -443,7 +443,7 @@ static uint32_t gpio_dw_get_power_state(const struct device *port)
static inline int gpio_dw_suspend_port(const struct device *port) static inline int gpio_dw_suspend_port(const struct device *port)
{ {
gpio_dw_clock_off(port); gpio_dw_clock_off(port);
gpio_dw_set_power_state(port, PM_DEVICE_SUSPEND_STATE); gpio_dw_set_power_state(port, PM_DEVICE_STATE_SUSPEND);
return 0; return 0;
} }
@ -451,7 +451,7 @@ static inline int gpio_dw_suspend_port(const struct device *port)
static inline int gpio_dw_resume_from_suspend_port(const struct device *port) static inline int gpio_dw_resume_from_suspend_port(const struct device *port)
{ {
gpio_dw_clock_on(port); gpio_dw_clock_on(port);
gpio_dw_set_power_state(port, PM_DEVICE_ACTIVE_STATE); gpio_dw_set_power_state(port, PM_DEVICE_STATE_ACTIVE);
return 0; return 0;
} }
@ -466,9 +466,9 @@ static int gpio_dw_device_ctrl(const struct device *port,
int ret = 0; int ret = 0;
if (ctrl_command == PM_DEVICE_STATE_SET) { if (ctrl_command == PM_DEVICE_STATE_SET) {
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) { if (*((uint32_t *)context) == PM_DEVICE_STATE_SUSPEND) {
ret = gpio_dw_suspend_port(port); ret = gpio_dw_suspend_port(port);
} else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) { } else if (*((uint32_t *)context) == PM_DEVICE_STATE_ACTIVE) {
ret = gpio_dw_resume_from_suspend_port(port); ret = gpio_dw_resume_from_suspend_port(port);
} }
} else if (ctrl_command == PM_DEVICE_STATE_GET) { } else if (ctrl_command == PM_DEVICE_STATE_GET) {
@ -544,7 +544,7 @@ static int gpio_dw_initialize(const struct device *port)
config->config_func(port); config->config_func(port);
} }
gpio_dw_set_power_state(port, PM_DEVICE_ACTIVE_STATE); gpio_dw_set_power_state(port, PM_DEVICE_STATE_ACTIVE);
return 0; return 0;
} }

View file

@ -466,7 +466,7 @@ static int gpio_stm32_config(const struct device *dev,
#ifdef CONFIG_PM_DEVICE_RUNTIME #ifdef CONFIG_PM_DEVICE_RUNTIME
/* Enable device clock before configuration (requires bank writes) */ /* Enable device clock before configuration (requires bank writes) */
if (data->power_state != PM_DEVICE_ACTIVE_STATE) { if (data->power_state != PM_DEVICE_STATE_ACTIVE) {
err = pm_device_get_sync(dev); err = pm_device_get_sync(dev);
if (err < 0) { if (err < 0) {
return err; return err;
@ -586,11 +586,11 @@ static int gpio_stm32_set_power_state(const struct device *dev,
struct gpio_stm32_data *data = dev->data; struct gpio_stm32_data *data = dev->data;
int ret = 0; int ret = 0;
if (new_state == PM_DEVICE_ACTIVE_STATE) { if (new_state == PM_DEVICE_STATE_ACTIVE) {
ret = gpio_stm32_clock_request(dev, true); ret = gpio_stm32_clock_request(dev, true);
} else if (new_state == PM_DEVICE_SUSPEND_STATE) { } else if (new_state == PM_DEVICE_STATE_SUSPEND) {
ret = gpio_stm32_clock_request(dev, false); ret = gpio_stm32_clock_request(dev, false);
} else if (new_state == PM_DEVICE_LOW_POWER_STATE) { } else if (new_state == PM_DEVICE_STATE_LOW_POWER) {
ret = gpio_stm32_clock_request(dev, false); ret = gpio_stm32_clock_request(dev, false);
} }
@ -660,13 +660,13 @@ static int gpio_stm32_init(const struct device *dev)
#endif #endif
#ifdef CONFIG_PM_DEVICE_RUNTIME #ifdef CONFIG_PM_DEVICE_RUNTIME
data->power_state = PM_DEVICE_OFF_STATE; data->power_state = PM_DEVICE_STATE_OFF;
pm_device_enable(dev); pm_device_enable(dev);
return 0; return 0;
#else #else
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
data->power_state = PM_DEVICE_ACTIVE_STATE; data->power_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return gpio_stm32_clock_request(dev, true); return gpio_stm32_clock_request(dev, true);
#endif #endif

View file

@ -333,7 +333,7 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if ((new_state == PM_DEVICE_ACTIVE_STATE) && if ((new_state == PM_DEVICE_STATE_ACTIVE) &&
(new_state != get_dev_data(dev)->pm_state)) { (new_state != get_dev_data(dev)->pm_state)) {
Power_setDependency(PowerCC26XX_PERIPH_I2C0); Power_setDependency(PowerCC26XX_PERIPH_I2C0);
IOCPinTypeI2c(get_dev_config(dev)->base, IOCPinTypeI2c(get_dev_config(dev)->base,
@ -346,11 +346,11 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
get_dev_data(dev)->pm_state = new_state; get_dev_data(dev)->pm_state = new_state;
} }
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) { if (get_dev_data(dev)->pm_state == PM_DEVICE_STATE_ACTIVE) {
I2CMasterIntDisable(get_dev_config(dev)->base); I2CMasterIntDisable(get_dev_config(dev)->base);
I2CMasterDisable(get_dev_config(dev)->base); I2CMasterDisable(get_dev_config(dev)->base);
/* Reset pin type to default GPIO configuration */ /* Reset pin type to default GPIO configuration */
@ -399,7 +399,7 @@ static int i2c_cc13xx_cc26xx_init(const struct device *dev)
int err; int err;
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
#ifdef CONFIG_PM #ifdef CONFIG_PM

View file

@ -215,7 +215,7 @@ static int init_twi(const struct device *dev)
return -EBUSY; return -EBUSY;
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return 0; return 0;
@ -234,7 +234,7 @@ static int twi_nrfx_pm_control(const struct device *dev,
if (new_state != pm_current_state) { if (new_state != pm_current_state) {
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
init_twi(dev); init_twi(dev);
if (get_dev_data(dev)->dev_config) { if (get_dev_data(dev)->dev_config) {
i2c_nrfx_twi_configure( i2c_nrfx_twi_configure(
@ -243,10 +243,10 @@ static int twi_nrfx_pm_control(const struct device *dev,
} }
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
if (pm_current_state == PM_DEVICE_ACTIVE_STATE) { if (pm_current_state == PM_DEVICE_STATE_ACTIVE) {
nrfx_twi_uninit(&get_dev_config(dev)->twi); nrfx_twi_uninit(&get_dev_config(dev)->twi);
} }
break; break;

View file

@ -254,7 +254,7 @@ static int init_twim(const struct device *dev)
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return 0; return 0;
@ -273,7 +273,7 @@ static int twim_nrfx_pm_control(const struct device *dev,
if (new_state != pm_current_state) { if (new_state != pm_current_state) {
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
init_twim(dev); init_twim(dev);
if (get_dev_data(dev)->dev_config) { if (get_dev_data(dev)->dev_config) {
i2c_nrfx_twim_configure( i2c_nrfx_twim_configure(
@ -282,10 +282,10 @@ static int twim_nrfx_pm_control(const struct device *dev,
} }
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
if (pm_current_state != PM_DEVICE_ACTIVE_STATE) { if (pm_current_state != PM_DEVICE_STATE_ACTIVE) {
break; break;
} }
nrfx_twim_uninit(&get_dev_config(dev)->twim); nrfx_twim_uninit(&get_dev_config(dev)->twim);

View file

@ -32,7 +32,7 @@ extern void *_VectorTable;
#define _ARC_V2_IRQ_VECT_BASE _ARC_V2_IRQ_VECT_BASE_S #define _ARC_V2_IRQ_VECT_BASE _ARC_V2_IRQ_VECT_BASE_S
#endif #endif
static uint32_t _arc_v2_irq_unit_device_power_state = PM_DEVICE_ACTIVE_STATE; static uint32_t _arc_v2_irq_unit_device_power_state = PM_DEVICE_STATE_ACTIVE;
struct arc_v2_irq_unit_ctx { struct arc_v2_irq_unit_ctx {
uint32_t irq_ctrl; /* Interrupt Context Saving Control Register. */ uint32_t irq_ctrl; /* Interrupt Context Saving Control Register. */
uint32_t irq_vect_base; /* Interrupt Vector Base. */ uint32_t irq_vect_base; /* Interrupt Vector Base. */
@ -120,7 +120,7 @@ static int arc_v2_irq_unit_suspend(const struct device *dev)
ctx.irq_ctrl = z_arc_v2_aux_reg_read(_ARC_V2_AUX_IRQ_CTRL); ctx.irq_ctrl = z_arc_v2_aux_reg_read(_ARC_V2_AUX_IRQ_CTRL);
ctx.irq_vect_base = z_arc_v2_aux_reg_read(_ARC_V2_IRQ_VECT_BASE); ctx.irq_vect_base = z_arc_v2_aux_reg_read(_ARC_V2_IRQ_VECT_BASE);
_arc_v2_irq_unit_device_power_state = PM_DEVICE_SUSPEND_STATE; _arc_v2_irq_unit_device_power_state = PM_DEVICE_STATE_SUSPEND;
return 0; return 0;
} }
@ -166,7 +166,7 @@ static int arc_v2_irq_unit_resume(const struct device *dev)
#endif #endif
z_arc_v2_aux_reg_write(_ARC_V2_IRQ_VECT_BASE, ctx.irq_vect_base); z_arc_v2_aux_reg_write(_ARC_V2_IRQ_VECT_BASE, ctx.irq_vect_base);
_arc_v2_irq_unit_device_power_state = PM_DEVICE_ACTIVE_STATE; _arc_v2_irq_unit_device_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }
@ -199,9 +199,9 @@ static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
unsigned int key = arch_irq_lock(); unsigned int key = arch_irq_lock();
if (ctrl_command == PM_DEVICE_STATE_SET) { if (ctrl_command == PM_DEVICE_STATE_SET) {
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) { if (*((uint32_t *)context) == PM_DEVICE_STATE_SUSPEND) {
ret = arc_v2_irq_unit_suspend(dev); ret = arc_v2_irq_unit_suspend(dev);
} else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) { } else if (*((uint32_t *)context) == PM_DEVICE_STATE_ACTIVE) {
ret = arc_v2_irq_unit_resume(dev); ret = arc_v2_irq_unit_resume(dev);
} }
} else if (ctrl_command == PM_DEVICE_STATE_GET) { } else if (ctrl_command == PM_DEVICE_STATE_GET) {

View file

@ -104,7 +104,7 @@ static uint32_t ioapic_rtes;
#define SUSPEND_BITS_REQD (ROUND_UP((256 * BITS_PER_IRQ), 32)) #define SUSPEND_BITS_REQD (ROUND_UP((256 * BITS_PER_IRQ), 32))
uint32_t ioapic_suspend_buf[SUSPEND_BITS_REQD / 32] = {0}; uint32_t ioapic_suspend_buf[SUSPEND_BITS_REQD / 32] = {0};
static uint32_t ioapic_device_power_state = PM_DEVICE_ACTIVE_STATE; static uint32_t ioapic_device_power_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
@ -311,17 +311,17 @@ static int ioapic_device_ctrl(const struct device *dev,
uint32_t new_state = *((uint32_t *)context); uint32_t new_state = *((uint32_t *)context);
switch (new_state) { switch (new_state) {
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
break; break;
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
if (ioapic_device_power_state != if (ioapic_device_power_state !=
PM_DEVICE_LOW_POWER_STATE) { PM_DEVICE_STATE_LOW_POWER) {
ret = ioapic_resume_from_suspend(dev); ret = ioapic_resume_from_suspend(dev);
} }
break; break;
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_FORCE_SUSPEND_STATE: case PM_DEVICE_STATE_FORCE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
ret = ioapic_suspend(dev); ret = ioapic_suspend(dev);
break; break;
default: default:

View file

@ -63,7 +63,7 @@
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
#include <pm/device.h> #include <pm/device.h>
uint32_t loapic_suspend_buf[LOPIC_SUSPEND_BITS_REQD / 32] = {0}; uint32_t loapic_suspend_buf[LOPIC_SUSPEND_BITS_REQD / 32] = {0};
static uint32_t loapic_device_power_state = PM_DEVICE_ACTIVE_STATE; static uint32_t loapic_device_power_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
#ifdef DEVICE_MMIO_IS_IN_RAM #ifdef DEVICE_MMIO_IS_IN_RAM
@ -364,7 +364,7 @@ static int loapic_suspend(const struct device *port)
} }
} }
} }
loapic_device_power_state = PM_DEVICE_SUSPEND_STATE; loapic_device_power_state = PM_DEVICE_STATE_SUSPEND;
return 0; return 0;
} }
@ -393,7 +393,7 @@ int loapic_resume(const struct device *port)
} }
} }
} }
loapic_device_power_state = PM_DEVICE_ACTIVE_STATE; loapic_device_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }
@ -409,9 +409,9 @@ static int loapic_device_ctrl(const struct device *port,
int ret = 0; int ret = 0;
if (ctrl_command == PM_DEVICE_STATE_SET) { if (ctrl_command == PM_DEVICE_STATE_SET) {
if (*context == PM_DEVICE_SUSPEND_STATE) { if (*context == PM_DEVICE_STATE_SUSPEND) {
ret = loapic_suspend(port); ret = loapic_suspend(port);
} else if (*context == PM_DEVICE_ACTIVE_STATE) { } else if (*context == PM_DEVICE_STATE_ACTIVE) {
ret = loapic_resume(port); ret = loapic_resume(port);
} }
} else if (ctrl_command == PM_DEVICE_STATE_GET) { } else if (ctrl_command == PM_DEVICE_STATE_GET) {

View file

@ -120,7 +120,7 @@ static int led_pwm_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
struct led_pwm_data *data = DEV_DATA(dev); struct led_pwm_data *data = DEV_DATA(dev);
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return 0; return 0;

View file

@ -3490,7 +3490,7 @@ static void shutdown_uart(void)
HL7800_IO_DBG_LOG("Power OFF the UART"); HL7800_IO_DBG_LOG("Power OFF the UART");
uart_irq_rx_disable(ictx.mdm_ctx.uart_dev); uart_irq_rx_disable(ictx.mdm_ctx.uart_dev);
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev, rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
PM_DEVICE_OFF_STATE, NULL, NULL); PM_DEVICE_STATE_OFF, NULL, NULL);
if (rc) { if (rc) {
LOG_ERR("Error disabling UART peripheral (%d)", rc); LOG_ERR("Error disabling UART peripheral (%d)", rc);
} }
@ -3507,7 +3507,7 @@ static void power_on_uart(void)
if (!ictx.uart_on) { if (!ictx.uart_on) {
HL7800_IO_DBG_LOG("Power ON the UART"); HL7800_IO_DBG_LOG("Power ON the UART");
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev, rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
PM_DEVICE_ACTIVE_STATE, NULL, NULL); PM_DEVICE_STATE_ACTIVE, NULL, NULL);
if (rc) { if (rc) {
LOG_ERR("Error enabling UART peripheral (%d)", rc); LOG_ERR("Error enabling UART peripheral (%d)", rc);
} }

View file

@ -198,16 +198,16 @@ int mdm_receiver_send(struct mdm_receiver_context *ctx,
int mdm_receiver_sleep(struct mdm_receiver_context *ctx) int mdm_receiver_sleep(struct mdm_receiver_context *ctx)
{ {
uart_irq_rx_disable(ctx->uart_dev); uart_irq_rx_disable(ctx->uart_dev);
#ifdef PM_DEVICE_LOW_POWER_STATE #ifdef PM_DEVICE_STATE_LOW_POWER
pm_device_state_set(ctx->uart_dev, PM_DEVICE_LOW_POWER_STATE, NULL, NULL); pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_LOW_POWER, NULL, NULL);
#endif #endif
return 0; return 0;
} }
int mdm_receiver_wake(struct mdm_receiver_context *ctx) int mdm_receiver_wake(struct mdm_receiver_context *ctx)
{ {
#ifdef PM_DEVICE_LOW_POWER_STATE #ifdef PM_DEVICE_STATE_LOW_POWER
pm_device_state_set(ctx->uart_dev, PM_DEVICE_ACTIVE_STATE, NULL, NULL); pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
#endif #endif
uart_irq_rx_enable(ctx->uart_dev); uart_irq_rx_enable(ctx->uart_dev);

View file

@ -297,14 +297,14 @@ static int pwm_nrfx_set_power_state(uint32_t new_state,
int err = 0; int err = 0;
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
err = pwm_nrfx_init(dev); err = pwm_nrfx_init(dev);
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_FORCE_SUSPEND_STATE: case PM_DEVICE_STATE_FORCE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
if (current_state == PM_DEVICE_ACTIVE_STATE) { if (current_state == PM_DEVICE_STATE_ACTIVE) {
pwm_nrfx_uninit(dev); pwm_nrfx_uninit(dev);
} }
break; break;
@ -348,7 +348,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
pm_device_cb cb, \ pm_device_cb cb, \
void *arg) \ void *arg) \
{ \ { \
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE; \ static uint32_t current_state = PM_DEVICE_STATE_ACTIVE; \
int ret = 0; \ int ret = 0; \
ret = pwm_nrfx_pm_control(dev, ctrl_command, state, \ ret = pwm_nrfx_pm_control(dev, ctrl_command, state, \
&current_state); \ &current_state); \

View file

@ -419,7 +419,7 @@ static int apds9960_device_ctrl(const struct device *dev,
if (ctrl_command == PM_DEVICE_STATE_SET) { if (ctrl_command == PM_DEVICE_STATE_SET) {
uint32_t device_pm_state = *(uint32_t *)context; uint32_t device_pm_state = *(uint32_t *)context;
if (device_pm_state == PM_DEVICE_ACTIVE_STATE) { if (device_pm_state == PM_DEVICE_STATE_ACTIVE) {
if (i2c_reg_update_byte(data->i2c, config->i2c_address, if (i2c_reg_update_byte(data->i2c, config->i2c_address,
APDS9960_ENABLE_REG, APDS9960_ENABLE_REG,
APDS9960_ENABLE_PON, APDS9960_ENABLE_PON,
@ -442,7 +442,7 @@ static int apds9960_device_ctrl(const struct device *dev,
} }
} else if (ctrl_command == PM_DEVICE_STATE_GET) { } else if (ctrl_command == PM_DEVICE_STATE_GET) {
*((uint32_t *)context) = PM_DEVICE_ACTIVE_STATE; *((uint32_t *)context) = PM_DEVICE_STATE_ACTIVE;
} }
if (cb) { if (cb) {

View file

@ -183,7 +183,7 @@ static int bme280_sample_fetch(const struct device *dev,
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
/* Do not allow sample fetching from OFF state */ /* Do not allow sample fetching from OFF state */
if (data->pm_state == PM_DEVICE_OFF_STATE) if (data->pm_state == PM_DEVICE_STATE_OFF)
return -EIO; return -EIO;
#endif #endif
@ -383,7 +383,7 @@ static int bme280_chip_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
/* Set power state to ACTIVE */ /* Set power state to ACTIVE */
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
LOG_DBG("\"%s\" OK", dev->name); LOG_DBG("\"%s\" OK", dev->name);
return 0; return 0;
@ -404,13 +404,13 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
if (new_pm_state != data->pm_state) { if (new_pm_state != data->pm_state) {
/* Switching from OFF to any */ /* Switching from OFF to any */
if (data->pm_state == PM_DEVICE_OFF_STATE) { if (data->pm_state == PM_DEVICE_STATE_OFF) {
/* Re-initialize the chip */ /* Re-initialize the chip */
ret = bme280_chip_init(dev); ret = bme280_chip_init(dev);
} }
/* Switching to OFF from any */ /* Switching to OFF from any */
else if (new_pm_state == PM_DEVICE_OFF_STATE) { else if (new_pm_state == PM_DEVICE_STATE_OFF) {
/* Put the chip into sleep mode */ /* Put the chip into sleep mode */
ret = bme280_reg_write(dev, ret = bme280_reg_write(dev,

View file

@ -313,7 +313,7 @@ static int bmp388_attr_set(const struct device *dev,
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
struct bmp388_data *data = DEV_DATA(dev); struct bmp388_data *data = DEV_DATA(dev);
if (data->device_power_state != PM_DEVICE_ACTIVE_STATE) { if (data->device_power_state != PM_DEVICE_STATE_ACTIVE) {
return -EBUSY; return -EBUSY;
} }
#endif #endif
@ -348,7 +348,7 @@ static int bmp388_sample_fetch(const struct device *dev,
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL); __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL);
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
if (bmp388->device_power_state != PM_DEVICE_ACTIVE_STATE) { if (bmp388->device_power_state != PM_DEVICE_STATE_ACTIVE) {
return -EBUSY; return -EBUSY;
} }
#endif #endif
@ -557,10 +557,10 @@ static int bmp388_set_power_state(const struct device *dev,
return 0; return 0;
} }
if (power_state == PM_DEVICE_ACTIVE_STATE) { if (power_state == PM_DEVICE_STATE_ACTIVE) {
reg_val = BMP388_PWR_CTRL_MODE_NORMAL; reg_val = BMP388_PWR_CTRL_MODE_NORMAL;
} else if ((power_state == PM_DEVICE_SUSPEND_STATE) || } else if ((power_state == PM_DEVICE_STATE_SUSPEND) ||
(power_state == PM_DEVICE_OFF_STATE)) { (power_state == PM_DEVICE_STATE_OFF)) {
reg_val = BMP388_PWR_CTRL_MODE_SLEEP; reg_val = BMP388_PWR_CTRL_MODE_SLEEP;
} else { } else {
return 0; return 0;
@ -672,7 +672,7 @@ static int bmp388_init(const struct device *dev)
} }
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
bmp388->device_power_state = PM_DEVICE_ACTIVE_STATE; bmp388->device_power_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
/* Read calibration data */ /* Read calibration data */

View file

@ -92,7 +92,7 @@ int bmp388_trigger_set(
struct bmp388_data *data = DEV_DATA(dev); struct bmp388_data *data = DEV_DATA(dev);
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
if (data->device_power_state != PM_DEVICE_ACTIVE_STATE) { if (data->device_power_state != PM_DEVICE_STATE_ACTIVE) {
return -EBUSY; return -EBUSY;
} }
#endif #endif

View file

@ -424,7 +424,7 @@ static int fdc2x1x_reset(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
struct fdc2x1x_data *data = dev->data; struct fdc2x1x_data *data = dev->data;
data->pm_state = PM_DEVICE_LOW_POWER_STATE; data->pm_state = PM_DEVICE_STATE_LOW_POWER;
#endif #endif
return ret; return ret;
@ -496,8 +496,8 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
const struct fdc2x1x_config *cfg = dev->config; const struct fdc2x1x_config *cfg = dev->config;
switch (pm_state) { switch (pm_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
if (data->pm_state == PM_DEVICE_OFF_STATE) { if (data->pm_state == PM_DEVICE_STATE_OFF) {
ret = fdc2x1x_set_shutdown(dev, false); ret = fdc2x1x_set_shutdown(dev, false);
if (ret) { if (ret) {
return ret; return ret;
@ -508,11 +508,11 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
if (ret) { if (ret) {
return ret; return ret;
} }
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
if (data->pm_state == PM_DEVICE_OFF_STATE) { if (data->pm_state == PM_DEVICE_STATE_OFF) {
ret = fdc2x1x_set_shutdown(dev, false); ret = fdc2x1x_set_shutdown(dev, false);
if (ret) { if (ret) {
return ret; return ret;
@ -522,13 +522,13 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
if (ret) { if (ret) {
return ret; return ret;
} }
data->pm_state = PM_DEVICE_LOW_POWER_STATE; data->pm_state = PM_DEVICE_STATE_LOW_POWER;
break; break;
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
if (cfg->sd_gpio->name) { if (cfg->sd_gpio->name) {
ret = fdc2x1x_set_shutdown(dev, true); ret = fdc2x1x_set_shutdown(dev, true);
data->pm_state = PM_DEVICE_OFF_STATE; data->pm_state = PM_DEVICE_STATE_OFF;
} else { } else {
LOG_ERR("SD pin not defined"); LOG_ERR("SD pin not defined");
ret = -EINVAL; ret = -EINVAL;
@ -553,9 +553,9 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
new_state = *(uint32_t *)context; new_state = *(uint32_t *)context;
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
ret = fdc2x1x_set_pm_state(dev, new_state); ret = fdc2x1x_set_pm_state(dev, new_state);
break; break;
default: default:
@ -655,7 +655,7 @@ static int fdc2x1x_sample_fetch(const struct device *dev,
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
struct fdc2x1x_data *data = dev->data; struct fdc2x1x_data *data = dev->data;
if (data->pm_state != PM_DEVICE_ACTIVE_STATE) { if (data->pm_state != PM_DEVICE_STATE_ACTIVE) {
LOG_ERR("Sample fetch failed, device is not in active mode"); LOG_ERR("Sample fetch failed, device is not in active mode");
return -ENXIO; return -ENXIO;
} }

View file

@ -25,7 +25,7 @@ static void fdc2x1x_thread_cb(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
/* INTB asserts after exiting shutdown mode. Drop this interrupt */ /* INTB asserts after exiting shutdown mode. Drop this interrupt */
if (drv_data->pm_state == PM_DEVICE_OFF_STATE) { if (drv_data->pm_state == PM_DEVICE_STATE_OFF) {
return; return;
} }
#endif #endif

View file

@ -470,7 +470,7 @@ static int lis2mdl_init(const struct device *dev)
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
lis2mdl->power_state = PM_DEVICE_ACTIVE_STATE; lis2mdl->power_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
#ifdef CONFIG_LIS2MDL_TRIGGER #ifdef CONFIG_LIS2MDL_TRIGGER
@ -490,7 +490,7 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
{ {
int status = 0; int status = 0;
if (new_state == PM_DEVICE_ACTIVE_STATE) { if (new_state == PM_DEVICE_STATE_ACTIVE) {
if (config->single_mode) { if (config->single_mode) {
status = lis2mdl_operating_mode_set(lis2mdl->ctx, status = lis2mdl_operating_mode_set(lis2mdl->ctx,
LIS2MDL_SINGLE_TRIGGER); LIS2MDL_SINGLE_TRIGGER);
@ -501,12 +501,12 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
if (status) { if (status) {
LOG_ERR("Power up failed"); LOG_ERR("Power up failed");
} }
lis2mdl->power_state = PM_DEVICE_ACTIVE_STATE; lis2mdl->power_state = PM_DEVICE_STATE_ACTIVE;
LOG_DBG("State changed to active"); LOG_DBG("State changed to active");
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
status = lis2mdl_operating_mode_set(lis2mdl->ctx, status = lis2mdl_operating_mode_set(lis2mdl->ctx,
LIS2MDL_POWER_DOWN); LIS2MDL_POWER_DOWN);
if (status) { if (status) {

View file

@ -209,7 +209,7 @@ static int qdec_nrfx_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
struct qdec_nrfx_data *data = &qdec_nrfx_data; struct qdec_nrfx_data *data = &qdec_nrfx_data;
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return 0; return 0;
@ -242,18 +242,18 @@ static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data,
return 0; return 0;
} }
if (old_state == PM_DEVICE_ACTIVE_STATE) { if (old_state == PM_DEVICE_STATE_ACTIVE) {
/* device must be suspended */ /* device must be suspended */
nrfx_qdec_disable(); nrfx_qdec_disable();
qdec_nrfx_gpio_ctrl(false); qdec_nrfx_gpio_ctrl(false);
} }
if (new_state == PM_DEVICE_OFF_STATE) { if (new_state == PM_DEVICE_STATE_OFF) {
/* device must be uninitialized */ /* device must be uninitialized */
nrfx_qdec_uninit(); nrfx_qdec_uninit();
} }
if (new_state == PM_DEVICE_ACTIVE_STATE) { if (new_state == PM_DEVICE_STATE_ACTIVE) {
qdec_nrfx_gpio_ctrl(true); qdec_nrfx_gpio_ctrl(true);
nrfx_qdec_enable(); nrfx_qdec_enable();
} }

View file

@ -238,7 +238,7 @@ static int vcnl4040_device_ctrl(const struct device *dev,
if (ret < 0) if (ret < 0)
return ret; return ret;
#endif #endif
if (device_pm_state == PM_DEVICE_ACTIVE_STATE) { if (device_pm_state == PM_DEVICE_STATE_ACTIVE) {
/* Clear proximity shutdown */ /* Clear proximity shutdown */
ps_conf &= ~VCNL4040_PS_SD_MASK; ps_conf &= ~VCNL4040_PS_SD_MASK;
@ -275,7 +275,7 @@ static int vcnl4040_device_ctrl(const struct device *dev,
} }
} else if (ctrl_command == PM_DEVICE_STATE_GET) { } else if (ctrl_command == PM_DEVICE_STATE_GET) {
*((uint32_t *)context) = PM_DEVICE_ACTIVE_STATE; *((uint32_t *)context) = PM_DEVICE_STATE_ACTIVE;
} }
if (cb) { if (cb) {

View file

@ -402,7 +402,7 @@ static int uart_cc13xx_cc26xx_set_power_state(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if ((new_state == PM_DEVICE_ACTIVE_STATE) && if ((new_state == PM_DEVICE_STATE_ACTIVE) &&
(new_state != get_dev_data(dev)->pm_state)) { (new_state != get_dev_data(dev)->pm_state)) {
if (get_dev_conf(dev)->regs == if (get_dev_conf(dev)->regs ==
DT_INST_REG_ADDR(0)) { DT_INST_REG_ADDR(0)) {
@ -417,11 +417,11 @@ static int uart_cc13xx_cc26xx_set_power_state(const struct device *dev,
get_dev_data(dev)->pm_state = new_state; get_dev_data(dev)->pm_state = new_state;
} }
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) { if (get_dev_data(dev)->pm_state == PM_DEVICE_STATE_ACTIVE) {
UARTDisable(get_dev_conf(dev)->regs); UARTDisable(get_dev_conf(dev)->regs);
/* /*
* Release power dependency - i.e. potentially power * Release power dependency - i.e. potentially power
@ -581,7 +581,7 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = {
#define UART_CC13XX_CC26XX_INIT_PM_STATE \ #define UART_CC13XX_CC26XX_INIT_PM_STATE \
do { \ do { \
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; \ get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE; \
} while (0) } while (0)
#else #else
#define UART_CC13XX_CC26XX_INIT_PM_STATE #define UART_CC13XX_CC26XX_INIT_PM_STATE

View file

@ -453,8 +453,8 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
struct uart_npcx_data *const data = DRV_DATA(dev); struct uart_npcx_data *const data = DRV_DATA(dev);
/* If next device power state is LOW or SUSPEND power state */ /* If next device power state is LOW or SUSPEND power state */
if (next_state == PM_DEVICE_LOW_POWER_STATE || if (next_state == PM_DEVICE_STATE_LOW_POWER ||
next_state == PM_DEVICE_SUSPEND_STATE) { next_state == PM_DEVICE_STATE_SUSPEND) {
/* /*
* If uart device is busy with transmitting, the driver will * If uart device is busy with transmitting, the driver will
* stay in while loop and wait for the transaction is completed. * stay in while loop and wait for the transaction is completed.

View file

@ -1140,7 +1140,7 @@ static void uart_nrfx_pins_enable(const struct device *dev, bool enable)
static void uart_nrfx_set_power_state(const struct device *dev, static void uart_nrfx_set_power_state(const struct device *dev,
uint32_t new_state) uint32_t new_state)
{ {
if (new_state == PM_DEVICE_ACTIVE_STATE) { if (new_state == PM_DEVICE_STATE_ACTIVE) {
uart_nrfx_pins_enable(dev, true); uart_nrfx_pins_enable(dev, true);
nrf_uart_enable(uart0_addr); nrf_uart_enable(uart0_addr);
if (RX_PIN_USED) { if (RX_PIN_USED) {
@ -1148,9 +1148,9 @@ static void uart_nrfx_set_power_state(const struct device *dev,
NRF_UART_TASK_STARTRX); NRF_UART_TASK_STARTRX);
} }
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
nrf_uart_disable(uart0_addr); nrf_uart_disable(uart0_addr);
uart_nrfx_pins_enable(dev, false); uart_nrfx_pins_enable(dev, false);
} }
@ -1160,7 +1160,7 @@ static int uart_nrfx_pm_control(const struct device *dev,
uint32_t ctrl_command, uint32_t ctrl_command,
uint32_t *state, pm_device_cb cb, void *arg) uint32_t *state, pm_device_cb cb, void *arg)
{ {
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE; static uint32_t current_state = PM_DEVICE_STATE_ACTIVE;
if (ctrl_command == PM_DEVICE_STATE_SET) { if (ctrl_command == PM_DEVICE_STATE_SET) {
uint32_t new_state = *state; uint32_t new_state = *state;

View file

@ -1377,7 +1377,7 @@ static void uarte_nrfx_poll_out(const struct device *dev, unsigned char c)
int key; int key;
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
if (data->pm_state != PM_DEVICE_ACTIVE_STATE) { if (data->pm_state != PM_DEVICE_STATE_ACTIVE) {
return; return;
} }
#endif #endif
@ -1670,7 +1670,7 @@ static int uarte_instance_init(const struct device *dev,
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
if (IS_ENABLED(CONFIG_UART_ENHANCED_POLL_OUT) && if (IS_ENABLED(CONFIG_UART_ENHANCED_POLL_OUT) &&
@ -1775,7 +1775,7 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
NRF_UARTE_Type *uarte = get_uarte_instance(dev); NRF_UARTE_Type *uarte = get_uarte_instance(dev);
struct uarte_nrfx_data *data = get_dev_data(dev); struct uarte_nrfx_data *data = get_dev_data(dev);
if (new_state == PM_DEVICE_ACTIVE_STATE) { if (new_state == PM_DEVICE_STATE_ACTIVE) {
uarte_nrfx_pins_enable(dev, true); uarte_nrfx_pins_enable(dev, true);
nrf_uarte_enable(uarte); nrf_uarte_enable(uarte);
@ -1803,14 +1803,14 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
#endif #endif
} }
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
/* if pm is already not active, driver will stay indefinitely /* if pm is already not active, driver will stay indefinitely
* in while loop waiting for event NRF_UARTE_EVENT_RXTO * in while loop waiting for event NRF_UARTE_EVENT_RXTO
*/ */
if (data->pm_state != PM_DEVICE_ACTIVE_STATE) { if (data->pm_state != PM_DEVICE_STATE_ACTIVE) {
return; return;
} }

View file

@ -1410,7 +1410,7 @@ static int uart_stm32_init(const struct device *dev)
config->uconf.irq_config_func(dev); config->uconf.irq_config_func(dev);
#endif #endif
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif /* CONFIG_PM_DEVICE */ #endif /* CONFIG_PM_DEVICE */
#ifdef CONFIG_UART_ASYNC_API #ifdef CONFIG_UART_ASYNC_API
@ -1428,7 +1428,7 @@ static int uart_stm32_set_power_state(const struct device *dev,
struct uart_stm32_data *data = DEV_DATA(dev); struct uart_stm32_data *data = DEV_DATA(dev);
/* setting a low power mode */ /* setting a low power mode */
if (new_state != PM_DEVICE_ACTIVE_STATE) { if (new_state != PM_DEVICE_STATE_ACTIVE) {
#ifdef USART_ISR_BUSY #ifdef USART_ISR_BUSY
/* Make sure that no USART transfer is on-going */ /* Make sure that no USART transfer is on-going */
while (LL_USART_IsActiveFlag_BUSY(UartInstance) == 1) { while (LL_USART_IsActiveFlag_BUSY(UartInstance) == 1) {

View file

@ -215,7 +215,7 @@ static int spi_cc13xx_cc26xx_set_power_state(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if ((new_state == PM_DEVICE_ACTIVE_STATE) && if ((new_state == PM_DEVICE_STATE_ACTIVE) &&
(new_state != get_dev_data(dev)->pm_state)) { (new_state != get_dev_data(dev)->pm_state)) {
if (get_dev_config(dev)->base == if (get_dev_config(dev)->base ==
DT_INST_REG_ADDR(0)) { DT_INST_REG_ADDR(0)) {
@ -225,11 +225,11 @@ static int spi_cc13xx_cc26xx_set_power_state(const struct device *dev,
} }
get_dev_data(dev)->pm_state = new_state; get_dev_data(dev)->pm_state = new_state;
} else { } else {
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_STATE_LOW_POWER ||
new_state == PM_DEVICE_SUSPEND_STATE || new_state == PM_DEVICE_STATE_SUSPEND ||
new_state == PM_DEVICE_OFF_STATE); new_state == PM_DEVICE_STATE_OFF);
if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) { if (get_dev_data(dev)->pm_state == PM_DEVICE_STATE_ACTIVE) {
SSIDisable(get_dev_config(dev)->base); SSIDisable(get_dev_config(dev)->base);
/* /*
* Release power dependency * Release power dependency
@ -338,7 +338,7 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
#define SPI_CC13XX_CC26XX_INIT_PM_STATE \ #define SPI_CC13XX_CC26XX_INIT_PM_STATE \
do { \ do { \
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; \ get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE; \
} while (0) } while (0)
#else #else
#define SPI_CC13XX_CC26XX_INIT_PM_STATE #define SPI_CC13XX_CC26XX_INIT_PM_STATE

View file

@ -277,7 +277,7 @@ static int init_spi(const struct device *dev)
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
dev_data->pm_state = PM_DEVICE_ACTIVE_STATE; dev_data->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return 0; return 0;
@ -297,16 +297,16 @@ static int spi_nrfx_pm_control(const struct device *dev,
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
ret = init_spi(dev); ret = init_spi(dev);
/* Force reconfiguration before next transfer */ /* Force reconfiguration before next transfer */
data->ctx.config = NULL; data->ctx.config = NULL;
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
if (data->pm_state == PM_DEVICE_ACTIVE_STATE) { if (data->pm_state == PM_DEVICE_STATE_ACTIVE) {
nrfx_spi_uninit(&config->spi); nrfx_spi_uninit(&config->spi);
} }
break; break;

View file

@ -324,8 +324,8 @@ static int init_spim(const struct device *dev)
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
data->pm_state = PM_DEVICE_ACTIVE_STATE; data->pm_state = PM_DEVICE_STATE_ACTIVE;
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_STATE_ACTIVE;
#endif #endif
return 0; return 0;
@ -345,16 +345,16 @@ static int spim_nrfx_pm_control(const struct device *dev,
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
switch (new_state) { switch (new_state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
ret = init_spim(dev); ret = init_spim(dev);
/* Force reconfiguration before next transfer */ /* Force reconfiguration before next transfer */
data->ctx.config = NULL; data->ctx.config = NULL;
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
if (data->pm_state == PM_DEVICE_ACTIVE_STATE) { if (data->pm_state == PM_DEVICE_STATE_ACTIVE) {
nrfx_spim_uninit(&config->spim); nrfx_spim_uninit(&config->spim);
} }
break; break;

View file

@ -24,24 +24,24 @@ extern "C" {
struct device; struct device;
/** @def PM_DEVICE_ACTIVE_STATE /** @def PM_DEVICE_STATE_ACTIVE
* *
* @brief device is in ACTIVE power state * @brief device is in ACTIVE power state
* *
* @details Normal operation of the device. All device context is retained. * @details Normal operation of the device. All device context is retained.
*/ */
#define PM_DEVICE_ACTIVE_STATE 1 #define PM_DEVICE_STATE_ACTIVE 1
/** @def PM_DEVICE_LOW_POWER_STATE /** @def PM_DEVICE_STATE_LOW_POWER
* *
* @brief device is in LOW power state * @brief device is in LOW power state
* *
* @details Device context is preserved by the HW and need not be * @details Device context is preserved by the HW and need not be
* restored by the driver. * restored by the driver.
*/ */
#define PM_DEVICE_LOW_POWER_STATE 2 #define PM_DEVICE_STATE_LOW_POWER 2
/** @def PM_DEVICE_SUSPEND_STATE /** @def PM_DEVICE_STATE_SUSPEND
* *
* @brief device is in SUSPEND power state * @brief device is in SUSPEND power state
* *
@ -49,9 +49,9 @@ struct device;
* Device drivers must save and restore or reinitialize any context * Device drivers must save and restore or reinitialize any context
* lost by the hardware * lost by the hardware
*/ */
#define PM_DEVICE_SUSPEND_STATE 3 #define PM_DEVICE_STATE_SUSPEND 3
/** @def PM_DEVICE_FORCE_SUSPEND_STATE /** @def PM_DEVICE_STATE_FORCE_SUSPEND
* *
* @brief device is in force SUSPEND power state * @brief device is in force SUSPEND power state
* *
@ -61,9 +61,9 @@ struct device;
* Most device context is lost by the hardware. Device drivers must * Most device context is lost by the hardware. Device drivers must
* save and restore or reinitialize any context lost by the hardware. * save and restore or reinitialize any context lost by the hardware.
*/ */
#define PM_DEVICE_FORCE_SUSPEND_STATE 4 #define PM_DEVICE_STATE_FORCE_SUSPEND 4
/** @def PM_DEVICE_OFF_STATE /** @def PM_DEVICE_STATE_OFF
* *
* @brief device is in OFF power state * @brief device is in OFF power state
* *
@ -71,25 +71,25 @@ struct device;
* The device context is lost when this state is entered, so the OS * The device context is lost when this state is entered, so the OS
* software will reinitialize the device when powering it back on * software will reinitialize the device when powering it back on
*/ */
#define PM_DEVICE_OFF_STATE 5 #define PM_DEVICE_STATE_OFF 5
/** @def PM_DEVICE_RESUMING_STATE /** @def PM_DEVICE_STATE_RESUMING
* *
* @brief device is resuming to active state. * @brief device is resuming to active state.
* *
* @details - The device was previously suspended and is now * @details - The device was previously suspended and is now
* transitioning to become ACTIVE. * transitioning to become ACTIVE.
*/ */
#define PM_DEVICE_RESUMING_STATE 6 #define PM_DEVICE_STATE_RESUMING 6
/** @def PM_DEVICE_SUSPENDING_STATE /** @def PM_DEVICE_STATE_SUSPENDING
* *
* @brief device is suspending. * @brief device is suspending.
* *
* @details - The device is currently transitioning from ACTIVE * @details - The device is currently transitioning from ACTIVE
* to SUSPEND. * to SUSPEND.
*/ */
#define PM_DEVICE_SUSPENDING_STATE 7 #define PM_DEVICE_STATE_SUSPENDING 7
/* Constants defining support device power commands */ /* Constants defining support device power commands */
#define PM_DEVICE_STATE_SET 1 #define PM_DEVICE_STATE_SET 1

View file

@ -66,17 +66,17 @@ void main(void)
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC); k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S); printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
rc = pm_device_state_set(cons, PM_DEVICE_LOW_POWER_STATE, NULL, NULL); rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER, NULL, NULL);
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC); k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
rc = pm_device_state_set(cons, PM_DEVICE_ACTIVE_STATE, NULL, NULL); rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
printk("Sleep %u s\n", SLEEP_S); printk("Sleep %u s\n", SLEEP_S);
k_sleep(K_SECONDS(SLEEP_S)); k_sleep(K_SECONDS(SLEEP_S));
printk("Sleep %u s with UART off\n", SLEEP_S); printk("Sleep %u s with UART off\n", SLEEP_S);
rc = pm_device_state_set(cons, PM_DEVICE_LOW_POWER_STATE, NULL, NULL); rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER, NULL, NULL);
k_sleep(K_SECONDS(SLEEP_S)); k_sleep(K_SECONDS(SLEEP_S));
rc = pm_device_state_set(cons, PM_DEVICE_ACTIVE_STATE, NULL, NULL); rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
printk("Entering system off; press BUTTON1 to restart\n"); printk("Entering system off; press BUTTON1 to restart\n");

View file

@ -151,7 +151,7 @@ void main(void)
#if IS_ENABLED(CONFIG_PM_DEVICE) #if IS_ENABLED(CONFIG_PM_DEVICE)
printk("Putting the flash device into low power state... "); printk("Putting the flash device into low power state... ");
err = pm_device_state_set(flash_dev, PM_DEVICE_LOW_POWER_STATE, err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_LOW_POWER,
NULL, NULL); NULL, NULL);
if (err != 0) { if (err != 0) {
printk("FAILED\n"); printk("FAILED\n");

View file

@ -79,11 +79,11 @@ void main(void)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
uint32_t p_state; uint32_t p_state;
p_state = PM_DEVICE_LOW_POWER_STATE; p_state = PM_DEVICE_STATE_LOW_POWER;
pm_device_state_set(dev, p_state, NULL, NULL); pm_device_state_set(dev, p_state, NULL, NULL);
printk("set low power state for 2s\n"); printk("set low power state for 2s\n");
k_sleep(K_MSEC(2000)); k_sleep(K_MSEC(2000));
p_state = PM_DEVICE_ACTIVE_STATE; p_state = PM_DEVICE_STATE_ACTIVE;
pm_device_state_set(dev, p_state, NULL, NULL); pm_device_state_set(dev, p_state, NULL, NULL);
#endif #endif
} }

View file

@ -43,13 +43,13 @@ static void pm_cb(const struct device *dev,
ARG_UNUSED(arg); ARG_UNUSED(arg);
switch (*(uint32_t *)context) { switch (*(uint32_t *)context) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
printk("Enter ACTIVE_STATE "); printk("Enter ACTIVE_STATE ");
break; break;
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
printk("Enter LOW_POWER_STATE "); printk("Enter LOW_POWER_STATE ");
break; break;
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
printk("Enter OFF_STATE "); printk("Enter OFF_STATE ");
break; break;
} }
@ -97,13 +97,13 @@ void main(void)
/* Testing the power modes */ /* Testing the power modes */
uint32_t p_state; uint32_t p_state;
p_state = PM_DEVICE_LOW_POWER_STATE; p_state = PM_DEVICE_STATE_LOW_POWER;
pm_device_state_set(dev, p_state, pm_cb, NULL); pm_device_state_set(dev, p_state, pm_cb, NULL);
p_state = PM_DEVICE_OFF_STATE; p_state = PM_DEVICE_STATE_OFF;
pm_device_state_set(dev, p_state, pm_cb, NULL); pm_device_state_set(dev, p_state, pm_cb, NULL);
p_state = PM_DEVICE_ACTIVE_STATE; p_state = PM_DEVICE_STATE_ACTIVE;
pm_device_state_set(dev, p_state, pm_cb, NULL); pm_device_state_set(dev, p_state, pm_cb, NULL);
#endif #endif
@ -132,10 +132,10 @@ void main(void)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
p_state = PM_DEVICE_OFF_STATE; p_state = PM_DEVICE_STATE_OFF;
pm_device_state_set(dev, p_state, pm_cb, NULL); pm_device_state_set(dev, p_state, pm_cb, NULL);
k_sleep(K_MSEC(2000)); k_sleep(K_MSEC(2000));
p_state = PM_DEVICE_ACTIVE_STATE; p_state = PM_DEVICE_STATE_ACTIVE;
pm_device_state_set(dev, p_state, pm_cb, NULL); pm_device_state_set(dev, p_state, pm_cb, NULL);
#elif CONFIG_FDC2X1X_TRIGGER_NONE #elif CONFIG_FDC2X1X_TRIGGER_NONE
k_sleep(K_MSEC(100)); k_sleep(K_MSEC(100));

View file

@ -37,7 +37,7 @@ static int dummy_open(const struct device *dev)
(void) k_condvar_wait(&dev->pm->condvar, &wait_mutex, K_FOREVER); (void) k_condvar_wait(&dev->pm->condvar, &wait_mutex, K_FOREVER);
k_mutex_unlock(&wait_mutex); k_mutex_unlock(&wait_mutex);
if (atomic_get(&dev->pm->state) == PM_DEVICE_ACTIVE_STATE) { if (atomic_get(&dev->pm->state) == PM_DEVICE_STATE_ACTIVE) {
printk("Dummy device resumed\n"); printk("Dummy device resumed\n");
ret = 0; ret = 0;
} else { } else {
@ -97,7 +97,7 @@ static uint32_t dummy_get_power_state(const struct device *dev)
static int dummy_suspend(const struct device *dev) static int dummy_suspend(const struct device *dev)
{ {
printk("child suspending..\n"); printk("child suspending..\n");
device_power_state = PM_DEVICE_SUSPEND_STATE; device_power_state = PM_DEVICE_STATE_SUSPEND;
return 0; return 0;
} }
@ -105,7 +105,7 @@ static int dummy_suspend(const struct device *dev)
static int dummy_resume_from_suspend(const struct device *dev) static int dummy_resume_from_suspend(const struct device *dev)
{ {
printk("child resuming..\n"); printk("child resuming..\n");
device_power_state = PM_DEVICE_ACTIVE_STATE; device_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }
@ -118,7 +118,7 @@ static int dummy_device_pm_ctrl(const struct device *dev,
switch (ctrl_command) { switch (ctrl_command) {
case PM_DEVICE_STATE_SET: case PM_DEVICE_STATE_SET:
if (*state == PM_DEVICE_ACTIVE_STATE) { if (*state == PM_DEVICE_STATE_ACTIVE) {
ret = dummy_resume_from_suspend(dev); ret = dummy_resume_from_suspend(dev);
} else { } else {
ret = dummy_suspend(dev); ret = dummy_suspend(dev);
@ -152,7 +152,7 @@ int dummy_init(const struct device *dev)
} }
pm_device_enable(dev); pm_device_enable(dev);
device_power_state = PM_DEVICE_ACTIVE_STATE; device_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }

View file

@ -33,7 +33,7 @@ static uint32_t dummy_get_power_state(const struct device *dev)
static int dummy_suspend(const struct device *dev) static int dummy_suspend(const struct device *dev)
{ {
printk("parent suspending..\n"); printk("parent suspending..\n");
parent_power_state = PM_DEVICE_SUSPEND_STATE; parent_power_state = PM_DEVICE_STATE_SUSPEND;
return 0; return 0;
} }
@ -41,7 +41,7 @@ static int dummy_suspend(const struct device *dev)
static int dummy_resume_from_suspend(const struct device *dev) static int dummy_resume_from_suspend(const struct device *dev)
{ {
printk("parent resuming..\n"); printk("parent resuming..\n");
parent_power_state = PM_DEVICE_ACTIVE_STATE; parent_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }
@ -54,7 +54,7 @@ static int dummy_parent_pm_ctrl(const struct device *dev,
switch (ctrl_command) { switch (ctrl_command) {
case PM_DEVICE_STATE_SET: case PM_DEVICE_STATE_SET:
if (*state == PM_DEVICE_ACTIVE_STATE) { if (*state == PM_DEVICE_STATE_ACTIVE) {
ret = dummy_resume_from_suspend(dev); ret = dummy_resume_from_suspend(dev);
} else { } else {
ret = dummy_suspend(dev); ret = dummy_suspend(dev);
@ -79,7 +79,7 @@ static const struct dummy_parent_api funcs = {
int dummy_parent_init(const struct device *dev) int dummy_parent_init(const struct device *dev)
{ {
pm_device_enable(dev); pm_device_enable(dev);
parent_power_state = PM_DEVICE_ACTIVE_STATE; parent_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }

View file

@ -5529,7 +5529,7 @@ static int cmd_net_suspend(const struct shell *shell, size_t argc,
dev = net_if_get_device(iface); dev = net_if_get_device(iface);
ret = pm_device_state_set(dev, PM_DEVICE_SUSPEND_STATE, ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND,
NULL, NULL); NULL, NULL);
if (ret != 0) { if (ret != 0) {
PR_INFO("Iface could not be suspended: "); PR_INFO("Iface could not be suspended: ");
@ -5574,7 +5574,7 @@ static int cmd_net_resume(const struct shell *shell, size_t argc,
dev = net_if_get_device(iface); dev = net_if_get_device(iface);
ret = pm_device_state_set(dev, PM_DEVICE_ACTIVE_STATE, ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE,
NULL, NULL); NULL, NULL);
if (ret != 0) { if (ret != 0) {
PR_INFO("Iface could not be resumed\n"); PR_INFO("Iface could not be resumed\n");

View file

@ -80,7 +80,7 @@ static bool should_suspend(const struct device *dev, uint32_t state)
* If the device is currently powered off or the request was * If the device is currently powered off or the request was
* to go to the same state, just ignore it. * to go to the same state, just ignore it.
*/ */
if ((current_state == PM_DEVICE_OFF_STATE) || if ((current_state == PM_DEVICE_STATE_OFF) ||
(current_state == state)) { (current_state == state)) {
return false; return false;
} }
@ -128,17 +128,17 @@ static int _pm_devices(uint32_t state)
int pm_suspend_devices(void) int pm_suspend_devices(void)
{ {
return _pm_devices(PM_DEVICE_SUSPEND_STATE); return _pm_devices(PM_DEVICE_STATE_SUSPEND);
} }
int pm_low_power_devices(void) int pm_low_power_devices(void)
{ {
return _pm_devices(PM_DEVICE_LOW_POWER_STATE); return _pm_devices(PM_DEVICE_STATE_LOW_POWER);
} }
int pm_force_suspend_devices(void) int pm_force_suspend_devices(void)
{ {
return _pm_devices(PM_DEVICE_FORCE_SUSPEND_STATE); return _pm_devices(PM_DEVICE_STATE_FORCE_SUSPEND);
} }
void pm_resume_devices(void) void pm_resume_devices(void)
@ -150,7 +150,7 @@ void pm_resume_devices(void)
device_idx_t idx = pm_devices[pmi]; device_idx_t idx = pm_devices[pmi];
pm_device_state_set(&all_devices[idx], pm_device_state_set(&all_devices[idx],
PM_DEVICE_ACTIVE_STATE, PM_DEVICE_STATE_ACTIVE,
NULL, NULL); NULL, NULL);
++pmi; ++pmi;
} }
@ -209,15 +209,15 @@ void pm_create_device_list(void)
const char *pm_device_state_str(uint32_t state) const char *pm_device_state_str(uint32_t state)
{ {
switch (state) { switch (state) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
return "active"; return "active";
case PM_DEVICE_LOW_POWER_STATE: case PM_DEVICE_STATE_LOW_POWER:
return "low power"; return "low power";
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
return "suspend"; return "suspend";
case PM_DEVICE_FORCE_SUSPEND_STATE: case PM_DEVICE_STATE_FORCE_SUSPEND:
return "force suspend"; return "force suspend";
case PM_DEVICE_OFF_STATE: case PM_DEVICE_STATE_OFF:
return "off"; return "off";
default: default:
return ""; return "";

View file

@ -41,31 +41,31 @@ static void pm_work_handler(struct k_work *work)
int ret = 0; int ret = 0;
switch (atomic_get(&dev->pm->state)) { switch (atomic_get(&dev->pm->state)) {
case PM_DEVICE_ACTIVE_STATE: case PM_DEVICE_STATE_ACTIVE:
if ((atomic_get(&dev->pm->usage) == 0) && if ((atomic_get(&dev->pm->usage) == 0) &&
dev->pm->enable) { dev->pm->enable) {
atomic_set(&dev->pm->state, atomic_set(&dev->pm->state,
PM_DEVICE_SUSPENDING_STATE); PM_DEVICE_STATE_SUSPENDING);
ret = pm_device_state_set(dev, PM_DEVICE_SUSPEND_STATE, ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND,
device_pm_callback, NULL); device_pm_callback, NULL);
} else { } else {
goto fsm_out; goto fsm_out;
} }
break; break;
case PM_DEVICE_SUSPEND_STATE: case PM_DEVICE_STATE_SUSPEND:
if ((atomic_get(&dev->pm->usage) > 0) || if ((atomic_get(&dev->pm->usage) > 0) ||
!dev->pm->enable) { !dev->pm->enable) {
atomic_set(&dev->pm->state, atomic_set(&dev->pm->state,
PM_DEVICE_RESUMING_STATE); PM_DEVICE_STATE_RESUMING);
ret = pm_device_state_set(dev, PM_DEVICE_ACTIVE_STATE, ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE,
device_pm_callback, NULL); device_pm_callback, NULL);
} else { } else {
goto fsm_out; goto fsm_out;
} }
break; break;
case PM_DEVICE_SUSPENDING_STATE: case PM_DEVICE_STATE_SUSPENDING:
__fallthrough; __fallthrough;
case PM_DEVICE_RESUMING_STATE: case PM_DEVICE_STATE_RESUMING:
/* Do nothing: We are waiting for device_pm_callback() */ /* Do nothing: We are waiting for device_pm_callback() */
break; break;
default: default:
@ -88,11 +88,11 @@ static int pm_device_request(const struct device *dev,
{ {
struct k_mutex request_mutex; struct k_mutex request_mutex;
__ASSERT((target_state == PM_DEVICE_ACTIVE_STATE) || __ASSERT((target_state == PM_DEVICE_STATE_ACTIVE) ||
(target_state == PM_DEVICE_SUSPEND_STATE), (target_state == PM_DEVICE_STATE_SUSPEND),
"Invalid device PM state requested"); "Invalid device PM state requested");
if (target_state == PM_DEVICE_ACTIVE_STATE) { if (target_state == PM_DEVICE_STATE_ACTIVE) {
if (atomic_inc(&dev->pm->usage) < 0) { if (atomic_inc(&dev->pm->usage) < 0) {
return 0; return 0;
} }
@ -116,11 +116,11 @@ static int pm_device_request(const struct device *dev,
*/ */
if (dev->pm->usage == 1) { if (dev->pm->usage == 1) {
(void)pm_device_state_set(dev, (void)pm_device_state_set(dev,
PM_DEVICE_ACTIVE_STATE, PM_DEVICE_STATE_ACTIVE,
NULL, NULL); NULL, NULL);
} else if (dev->pm->usage == 0) { } else if (dev->pm->usage == 0) {
(void)pm_device_state_set(dev, (void)pm_device_state_set(dev,
PM_DEVICE_SUSPEND_STATE, PM_DEVICE_STATE_SUSPEND,
NULL, NULL); NULL, NULL);
} }
@ -150,23 +150,23 @@ static int pm_device_request(const struct device *dev,
int pm_device_get(const struct device *dev) int pm_device_get(const struct device *dev)
{ {
return pm_device_request(dev, return pm_device_request(dev,
PM_DEVICE_ACTIVE_STATE, PM_DEVICE_ASYNC); PM_DEVICE_STATE_ACTIVE, PM_DEVICE_ASYNC);
} }
int pm_device_get_sync(const struct device *dev) int pm_device_get_sync(const struct device *dev)
{ {
return pm_device_request(dev, PM_DEVICE_ACTIVE_STATE, 0); return pm_device_request(dev, PM_DEVICE_STATE_ACTIVE, 0);
} }
int pm_device_put(const struct device *dev) int pm_device_put(const struct device *dev)
{ {
return pm_device_request(dev, return pm_device_request(dev,
PM_DEVICE_SUSPEND_STATE, PM_DEVICE_ASYNC); PM_DEVICE_STATE_SUSPEND, PM_DEVICE_ASYNC);
} }
int pm_device_put_sync(const struct device *dev) int pm_device_put_sync(const struct device *dev)
{ {
return pm_device_request(dev, PM_DEVICE_SUSPEND_STATE, 0); return pm_device_request(dev, PM_DEVICE_STATE_SUSPEND, 0);
} }
void pm_device_enable(const struct device *dev) void pm_device_enable(const struct device *dev)
@ -176,7 +176,7 @@ void pm_device_enable(const struct device *dev)
if (k_is_pre_kernel()) { if (k_is_pre_kernel()) {
dev->pm->dev = dev; dev->pm->dev = dev;
dev->pm->enable = true; dev->pm->enable = true;
atomic_set(&dev->pm->state, PM_DEVICE_SUSPEND_STATE); atomic_set(&dev->pm->state, PM_DEVICE_STATE_SUSPEND);
k_work_init_delayable(&dev->pm->work, pm_work_handler); k_work_init_delayable(&dev->pm->work, pm_work_handler);
return; return;
} }
@ -190,7 +190,7 @@ void pm_device_enable(const struct device *dev)
*/ */
if (!dev->pm->dev) { if (!dev->pm->dev) {
dev->pm->dev = dev; dev->pm->dev = dev;
atomic_set(&dev->pm->state, PM_DEVICE_SUSPEND_STATE); atomic_set(&dev->pm->state, PM_DEVICE_STATE_SUSPEND);
k_work_init_delayable(&dev->pm->work, pm_work_handler); k_work_init_delayable(&dev->pm->work, pm_work_handler);
} else { } else {
k_work_schedule(&dev->pm->work, K_NO_WAIT); k_work_schedule(&dev->pm->work, K_NO_WAIT);

View file

@ -146,7 +146,7 @@ static int cmd_device_list(const struct shell *shell,
state = "DISABLED"; state = "DISABLED";
} else { } else {
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
uint32_t st = PM_DEVICE_ACTIVE_STATE; uint32_t st = PM_DEVICE_STATE_ACTIVE;
int err = pm_device_state_get(dev, &st); int err = pm_device_state_get(dev, &st);
if (!err) { if (!err) {

View file

@ -316,8 +316,8 @@ void test_dummy_device_pm(void)
test_build_suspend_device_list(); test_build_suspend_device_list();
/* Set device state to PM_DEVICE_ACTIVE_STATE */ /* Set device state to PM_DEVICE_STATE_ACTIVE */
ret = pm_device_state_set(dev, PM_DEVICE_ACTIVE_STATE, NULL, NULL); ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
if (ret == -ENOSYS) { if (ret == -ENOSYS) {
TC_PRINT("Power management not supported on device"); TC_PRINT("Power management not supported on device");
ztest_test_skip(); ztest_test_skip();
@ -330,19 +330,19 @@ void test_dummy_device_pm(void)
ret = pm_device_state_get(dev, &device_power_state); ret = pm_device_state_get(dev, &device_power_state);
zassert_true((ret == 0), zassert_true((ret == 0),
"Unable to get active state to device"); "Unable to get active state to device");
zassert_true((device_power_state == PM_DEVICE_ACTIVE_STATE), zassert_true((device_power_state == PM_DEVICE_STATE_ACTIVE),
"Error power status"); "Error power status");
/* Set device state to PM_DEVICE_FORCE_SUSPEND_STATE */ /* Set device state to PM_DEVICE_STATE_FORCE_SUSPEND */
ret = pm_device_state_set(dev, ret = pm_device_state_set(dev,
PM_DEVICE_FORCE_SUSPEND_STATE, NULL, NULL); PM_DEVICE_STATE_FORCE_SUSPEND, NULL, NULL);
zassert_true((ret == 0), "Unable to force suspend device"); zassert_true((ret == 0), "Unable to force suspend device");
ret = pm_device_state_get(dev, &device_power_state); ret = pm_device_state_get(dev, &device_power_state);
zassert_true((ret == 0), zassert_true((ret == 0),
"Unable to get suspend state to device"); "Unable to get suspend state to device");
zassert_true((device_power_state == PM_DEVICE_ACTIVE_STATE), zassert_true((device_power_state == PM_DEVICE_STATE_ACTIVE),
"Error power status"); "Error power status");
} }
#else #else

View file

@ -28,12 +28,12 @@ static int fake_dev_pm_control(const struct device *dev, uint32_t command,
int ret = 0; int ret = 0;
if (command == PM_DEVICE_STATE_SET) { if (command == PM_DEVICE_STATE_SET) {
if (*state == PM_DEVICE_SUSPEND_STATE) { if (*state == PM_DEVICE_STATE_SUSPEND) {
ret = net_if_suspend(ctx->iface); ret = net_if_suspend(ctx->iface);
if (ret == -EBUSY) { if (ret == -EBUSY) {
goto out; goto out;
} }
} else if (*state == PM_DEVICE_ACTIVE_STATE) { } else if (*state == PM_DEVICE_STATE_ACTIVE) {
ret = net_if_resume(ctx->iface); ret = net_if_resume(ctx->iface);
} }
} else { } else {
@ -149,13 +149,13 @@ void test_pm(void)
*/ */
k_yield(); k_yield();
ret = pm_device_state_set(dev, PM_DEVICE_SUSPEND_STATE, NULL, NULL); ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND, NULL, NULL);
zassert_true(ret == 0, "Could not set state"); zassert_true(ret == 0, "Could not set state");
zassert_true(net_if_is_suspended(iface), "net iface is not suspended"); zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
/* Let's try to suspend it again, it should fail relevantly */ /* Let's try to suspend it again, it should fail relevantly */
ret = pm_device_state_set(dev, PM_DEVICE_SUSPEND_STATE, NULL, NULL); ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND, NULL, NULL);
zassert_true(ret == -EALREADY, "Could change state"); zassert_true(ret == -EALREADY, "Could change state");
zassert_true(net_if_is_suspended(iface), "net iface is not suspended"); zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
@ -165,12 +165,12 @@ void test_pm(void)
(struct sockaddr *)&addr4, sizeof(struct sockaddr_in)); (struct sockaddr *)&addr4, sizeof(struct sockaddr_in));
zassert_true(ret < 0, "Could send data"); zassert_true(ret < 0, "Could send data");
ret = pm_device_state_set(dev, PM_DEVICE_ACTIVE_STATE, NULL, NULL); ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
zassert_true(ret == 0, "Could not set state"); zassert_true(ret == 0, "Could not set state");
zassert_false(net_if_is_suspended(iface), "net iface is suspended"); zassert_false(net_if_is_suspended(iface), "net iface is suspended");
ret = pm_device_state_set(dev, PM_DEVICE_ACTIVE_STATE, NULL, NULL); ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
zassert_true(ret == -EALREADY, "Could change state"); zassert_true(ret == -EALREADY, "Could change state");
/* Let's send some data, it should go through */ /* Let's send some data, it should go through */

View file

@ -28,13 +28,13 @@ static uint32_t dummy_get_power_state(const struct device *dev)
static int dummy_suspend(const struct device *dev) static int dummy_suspend(const struct device *dev)
{ {
device_power_state = PM_DEVICE_SUSPEND_STATE; device_power_state = PM_DEVICE_STATE_SUSPEND;
return 0; return 0;
} }
static int dummy_resume_from_suspend(const struct device *dev) static int dummy_resume_from_suspend(const struct device *dev)
{ {
device_power_state = PM_DEVICE_ACTIVE_STATE; device_power_state = PM_DEVICE_STATE_ACTIVE;
return 0; return 0;
} }
@ -46,7 +46,7 @@ static int dummy_device_pm_ctrl(const struct device *dev,
switch (ctrl_command) { switch (ctrl_command) {
case PM_DEVICE_STATE_SET: case PM_DEVICE_STATE_SET:
if (*state == PM_DEVICE_ACTIVE_STATE) { if (*state == PM_DEVICE_STATE_ACTIVE) {
ret = dummy_resume_from_suspend(dev); ret = dummy_resume_from_suspend(dev);
} else { } else {
ret = dummy_suspend(dev); ret = dummy_suspend(dev);

View file

@ -42,7 +42,7 @@ __weak void pm_power_state_set(struct pm_state_info info)
uint32_t device_power_state; uint32_t device_power_state;
/* at this point, devices have been deactivated */ /* at this point, devices have been deactivated */
pm_device_state_get(dev, &device_power_state); pm_device_state_get(dev, &device_power_state);
zassert_false(device_power_state == PM_DEVICE_ACTIVE_STATE, NULL); zassert_false(device_power_state == PM_DEVICE_STATE_ACTIVE, NULL);
/* this function is called when system entering low power state, so /* this function is called when system entering low power state, so
* parameter state should not be PM_STATE_ACTIVE * parameter state should not be PM_STATE_ACTIVE
@ -95,7 +95,7 @@ static void notify_pm_state_entry(enum pm_state state)
/* at this point, devices should not be active */ /* at this point, devices should not be active */
pm_device_state_get(dev, &device_power_state); pm_device_state_get(dev, &device_power_state);
zassert_false(device_power_state == PM_DEVICE_ACTIVE_STATE, NULL); zassert_false(device_power_state == PM_DEVICE_STATE_ACTIVE, NULL);
set_pm = true; set_pm = true;
notify_app_exit = true; notify_app_exit = true;
} }
@ -113,7 +113,7 @@ static void notify_pm_state_exit(enum pm_state state)
/* at this point, devices are active again*/ /* at this point, devices are active again*/
pm_device_state_get(dev, &device_power_state); pm_device_state_get(dev, &device_power_state);
zassert_equal(device_power_state, PM_DEVICE_ACTIVE_STATE, NULL); zassert_equal(device_power_state, PM_DEVICE_STATE_ACTIVE, NULL);
leave_idle = true; leave_idle = true;
} }
@ -180,11 +180,11 @@ void test_power_state_notification(void)
uint32_t device_power_state; uint32_t device_power_state;
pm_device_state_get(dev, &device_power_state); pm_device_state_get(dev, &device_power_state);
zassert_equal(device_power_state, PM_DEVICE_ACTIVE_STATE, NULL); zassert_equal(device_power_state, PM_DEVICE_STATE_ACTIVE, NULL);
api->close(dev); api->close(dev);
pm_device_state_get(dev, &device_power_state); pm_device_state_get(dev, &device_power_state);
zassert_equal(device_power_state, PM_DEVICE_SUSPEND_STATE, NULL); zassert_equal(device_power_state, PM_DEVICE_STATE_SUSPEND, NULL);
/* reopen device as it will be closed in teardown */ /* reopen device as it will be closed in teardown */
api->open(dev); api->open(dev);
} }