pm: replace DEVICE_PM_* states with PM_DEVICE_*

Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-05-03 17:36:10 +02:00 committed by Anas Nashif
commit 2c7b763e47
52 changed files with 331 additions and 331 deletions

View file

@ -215,20 +215,20 @@ registers, clocks, memory etc.
The four device power states: The four device power states:
:code:`DEVICE_PM_ACTIVE_STATE` :code:`PM_DEVICE_ACTIVE_STATE`
Normal operation of the device. All device context is retained. Normal operation of the device. All device context is retained.
:code:`DEVICE_PM_LOW_POWER_STATE` :code:`PM_DEVICE_LOW_POWER_STATE`
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:`DEVICE_PM_SUSPEND_STATE` :code:`PM_DEVICE_SUSPEND_STATE`
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:`DEVICE_PM_OFF_STATE` :code:`PM_DEVICE_OFF_STATE`
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
@ -241,8 +241,8 @@ Zephyr RTOS power management subsystem provides a control function interface
to device drivers to indicate power management operations to perform. to device drivers to indicate power management operations to perform.
The supported PM control commands are: The supported PM control commands are:
* DEVICE_PM_SET_POWER_STATE * PM_DEVICE_SET_POWER_STATE
* DEVICE_PM_GET_POWER_STATE * PM_DEVICE_GET_POWER_STATE
Each device driver defines: Each device driver defines:
@ -298,7 +298,7 @@ Device Set Power State
int device_set_power_state(const struct device *dev, uint32_t device_power_state, device_pm_cb cb, void *arg); int device_set_power_state(const struct device *dev, uint32_t device_power_state, device_pm_cb cb, void *arg);
Calls the :c:func:`device_pm_control()` handler function implemented by the Calls the :c:func:`device_pm_control()` handler function implemented by the
device driver with DEVICE_PM_SET_POWER_STATE command. device driver with PM_DEVICE_SET_POWER_STATE command.
Device Get Power State Device Get Power State
---------------------- ----------------------
@ -308,7 +308,7 @@ Device Get Power State
int device_get_power_state(const struct device *dev, uint32_t * device_power_state); int device_get_power_state(const struct device *dev, uint32_t * device_power_state);
Calls the :c:func:`device_pm_control()` handler function implemented by the Calls the :c:func:`device_pm_control()` handler function implemented by the
device driver with DEVICE_PM_GET_POWER_STATE command. device driver with PM_DEVICE_GET_POWER_STATE command.
Busy Status Indication Busy Status Indication
====================== ======================

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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
data->cmd_data_dev = device_get_binding(config->cmd_data.name); data->cmd_data_dev = device_get_binding(config->cmd_data.name);
@ -526,24 +526,24 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = (struct st7735r_data *)dev->data;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = st7735r_exit_sleep(data); ret = st7735r_exit_sleep(data);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
data->pm_state = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
} 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 = DEVICE_PM_LOW_POWER_STATE; data->pm_state = PM_DEVICE_LOW_POWER_STATE;
} }
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
data->cmd_data_gpio = device_get_binding( data->cmd_data_gpio = device_get_binding(
@ -415,18 +415,18 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
struct st7789v_data *data = (struct st7789v_data *)dev->data; struct st7789v_data *data = (struct st7789v_data *)dev->data;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
st7789v_exit_sleep(data); st7789v_exit_sleep(data);
data->pm_state = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
ret = 0; ret = 0;
} else { } else {
st7789v_enter_sleep(data); st7789v_enter_sleep(data);
data->pm_state = DEVICE_PM_LOW_POWER_STATE; data->pm_state = PM_DEVICE_LOW_POWER_STATE;
ret = 0; ret = 0;
} }
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
break; break;
default: default:

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 == DEVICE_PM_ACTIVE_STATE) && if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
(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 == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
if (data->pm_state == DEVICE_PM_ACTIVE_STATE) { if (data->pm_state == PM_DEVICE_ACTIVE_STATE) {
stop_trng(data); stop_trng(data);
Power_releaseDependency(PowerCC26XX_PERIPH_TRNG); Power_releaseDependency(PowerCC26XX_PERIPH_TRNG);
} }
@ -299,7 +299,7 @@ static int entropy_cc13xx_cc26xx_pm_control(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 (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
@ -307,7 +307,7 @@ static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
new_state); new_state);
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }
@ -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 = DEVICE_PM_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
/* Initialize driver data */ /* Initialize driver data */

View file

@ -198,8 +198,8 @@ static int eth_mcux_device_pm_control(const struct device *dev,
goto out; goto out;
} }
if (command == DEVICE_PM_SET_POWER_STATE) { if (command == PM_DEVICE_SET_POWER_STATE) {
if (*(uint32_t *)context == DEVICE_PM_SUSPEND_STATE) { if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
LOG_DBG("Suspending"); LOG_DBG("Suspending");
ret = net_if_suspend(eth_ctx->iface); ret = net_if_suspend(eth_ctx->iface);
@ -214,7 +214,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 (*(uint32_t *)context == DEVICE_PM_ACTIVE_STATE) { } else if (*(uint32_t *)context == PM_DEVICE_ACTIVE_STATE) {
LOG_DBG("Resuming"); LOG_DBG("Resuming");
clock_control_on(eth_ctx->clock_dev, clock_control_on(eth_ctx->clock_dev,

View file

@ -576,21 +576,21 @@ static int spi_flash_at45_pm_control(const struct device *dev,
const struct spi_flash_at45_config *dev_config = get_dev_config(dev); const struct spi_flash_at45_config *dev_config = get_dev_config(dev);
int err = 0; int err = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != dev_data->pm_state) { if (new_state != dev_data->pm_state) {
switch (new_state) { switch (new_state) {
case DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
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 DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
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
@ -606,7 +606,7 @@ static int spi_flash_at45_pm_control(const struct device *dev,
dev_data->pm_state = new_state; dev_data->pm_state = new_state;
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = dev_data->pm_state; *((uint32_t *)context) = dev_data->pm_state;
} }
@ -647,7 +647,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 = DEVICE_PM_ACTIVE_STATE)) \ .pm_state = PM_DEVICE_ACTIVE_STATE)) \
}; \ }; \
static const struct spi_flash_at45_config inst_##idx##_config = { \ static const struct spi_flash_at45_config inst_##idx##_config = { \
.spi_bus = DT_INST_BUS_LABEL(idx), \ .spi_bus = DT_INST_BUS_LABEL(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:
* * DEVICE_PM_ACTIVE_STATE covers both active and standby modes; * * PM_DEVICE_ACTIVE_STATE covers both active and standby modes;
* * DEVICE_PM_LOW_POWER_STATE, DEVICE_PM_SUSPEND_STATE, and * * PM_DEVICE_LOW_POWER_STATE, PM_DEVICE_SUSPEND_STATE, and
* DEVICE_PM_OFF_STATE all correspond to deep-power-down mode. * PM_DEVICE_OFF_STATE 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, DEVICE_PM_SUSPEND_STATE); gpio_dw_set_power_state(port, PM_DEVICE_SUSPEND_STATE);
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, DEVICE_PM_ACTIVE_STATE); gpio_dw_set_power_state(port, PM_DEVICE_ACTIVE_STATE);
return 0; return 0;
} }
@ -465,13 +465,13 @@ static int gpio_dw_device_ctrl(const struct device *port,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) { if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
ret = gpio_dw_suspend_port(port); ret = gpio_dw_suspend_port(port);
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { } else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = gpio_dw_resume_from_suspend_port(port); ret = gpio_dw_resume_from_suspend_port(port);
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = gpio_dw_get_power_state(port); *((uint32_t *)context) = gpio_dw_get_power_state(port);
} }
@ -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, DEVICE_PM_ACTIVE_STATE); gpio_dw_set_power_state(port, PM_DEVICE_ACTIVE_STATE);
return 0; return 0;
} }

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 == DEVICE_PM_ACTIVE_STATE) && if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
(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 == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
if (get_dev_data(dev)->pm_state == DEVICE_PM_ACTIVE_STATE) { if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) {
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 */
@ -373,7 +373,7 @@ static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != get_dev_data(dev)->pm_state) { if (new_state != get_dev_data(dev)->pm_state) {
@ -381,7 +381,7 @@ static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
new_state); new_state);
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = get_dev_data(dev)->pm_state; *((uint32_t *)context) = get_dev_data(dev)->pm_state;
} }
@ -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 = DEVICE_PM_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
#ifdef CONFIG_PM #ifdef CONFIG_PM

View file

@ -206,7 +206,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 = DEVICE_PM_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
return 0; return 0;
@ -220,12 +220,12 @@ static int twi_nrfx_pm_control(const struct device *dev,
int ret = 0; int ret = 0;
uint32_t pm_current_state = get_dev_data(dev)->pm_state; uint32_t pm_current_state = get_dev_data(dev)->pm_state;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != pm_current_state) { if (new_state != pm_current_state) {
switch (new_state) { switch (new_state) {
case DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
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(
@ -234,10 +234,10 @@ static int twi_nrfx_pm_control(const struct device *dev,
} }
break; break;
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
if (pm_current_state == DEVICE_PM_ACTIVE_STATE) { if (pm_current_state == PM_DEVICE_ACTIVE_STATE) {
nrfx_twi_uninit(&get_dev_config(dev)->twi); nrfx_twi_uninit(&get_dev_config(dev)->twi);
} }
break; break;
@ -250,7 +250,7 @@ static int twi_nrfx_pm_control(const struct device *dev,
} }
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = get_dev_data(dev)->pm_state; *((uint32_t *)context) = get_dev_data(dev)->pm_state;
} }

View file

@ -256,7 +256,7 @@ static int init_twim(const struct device *dev)
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
return 0; return 0;
@ -270,12 +270,12 @@ static int twim_nrfx_pm_control(const struct device *dev,
int ret = 0; int ret = 0;
uint32_t pm_current_state = get_dev_data(dev)->pm_state; uint32_t pm_current_state = get_dev_data(dev)->pm_state;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != pm_current_state) { if (new_state != pm_current_state) {
switch (new_state) { switch (new_state) {
case DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
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(
@ -284,10 +284,10 @@ static int twim_nrfx_pm_control(const struct device *dev,
} }
break; break;
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
if (pm_current_state != DEVICE_PM_ACTIVE_STATE) { if (pm_current_state != PM_DEVICE_ACTIVE_STATE) {
break; break;
} }
nrfx_twim_uninit(&get_dev_config(dev)->twim); nrfx_twim_uninit(&get_dev_config(dev)->twim);
@ -301,7 +301,7 @@ static int twim_nrfx_pm_control(const struct device *dev,
} }
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = get_dev_data(dev)->pm_state; *((uint32_t *)context) = get_dev_data(dev)->pm_state;
} }

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 = DEVICE_PM_ACTIVE_STATE; static uint32_t _arc_v2_irq_unit_device_power_state = PM_DEVICE_ACTIVE_STATE;
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 = DEVICE_PM_SUSPEND_STATE; _arc_v2_irq_unit_device_power_state = PM_DEVICE_SUSPEND_STATE;
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 = DEVICE_PM_ACTIVE_STATE; _arc_v2_irq_unit_device_power_state = PM_DEVICE_ACTIVE_STATE;
return 0; return 0;
} }
@ -198,13 +198,13 @@ static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
int ret = 0; int ret = 0;
unsigned int key = arch_irq_lock(); unsigned int key = arch_irq_lock();
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) { if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
ret = arc_v2_irq_unit_suspend(dev); ret = arc_v2_irq_unit_suspend(dev);
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { } else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = arc_v2_irq_unit_resume(dev); ret = arc_v2_irq_unit_resume(dev);
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = arc_v2_irq_unit_get_state(dev); *((uint32_t *)context) = arc_v2_irq_unit_get_state(dev);
} }

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 = DEVICE_PM_ACTIVE_STATE; static uint32_t ioapic_device_power_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
@ -265,7 +265,7 @@ int ioapic_suspend(const struct device *port)
store_flags(irq, rte_lo); store_flags(irq, rte_lo);
} }
} }
ioapic_device_power_state = DEVICE_PM_SUSPEND_STATE; ioapic_device_power_state = PM_DEVICE_SUSPEND_STATE;
return 0; return 0;
} }
@ -295,7 +295,7 @@ int ioapic_resume_from_suspend(const struct device *port)
ioApicRedSetHi(irq, DEFAULT_RTE_DEST); ioApicRedSetHi(irq, DEFAULT_RTE_DEST);
ioApicRedSetLo(irq, rteValue); ioApicRedSetLo(irq, rteValue);
} }
ioapic_device_power_state = DEVICE_PM_ACTIVE_STATE; ioapic_device_power_state = PM_DEVICE_ACTIVE_STATE;
return 0; return 0;
} }
@ -309,13 +309,13 @@ static int ioapic_device_ctrl(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) { if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
ret = ioapic_suspend(dev); ret = ioapic_suspend(dev);
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { } else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = ioapic_resume_from_suspend(dev); ret = ioapic_resume_from_suspend(dev);
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = ioapic_device_power_state; *((uint32_t *)context) = ioapic_device_power_state;
} }

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 = DEVICE_PM_ACTIVE_STATE; static uint32_t loapic_device_power_state = PM_DEVICE_ACTIVE_STATE;
#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 = DEVICE_PM_SUSPEND_STATE; loapic_device_power_state = PM_DEVICE_SUSPEND_STATE;
return 0; return 0;
} }
@ -393,7 +393,7 @@ int loapic_resume(const struct device *port)
} }
} }
} }
loapic_device_power_state = DEVICE_PM_ACTIVE_STATE; loapic_device_power_state = PM_DEVICE_ACTIVE_STATE;
return 0; return 0;
} }
@ -408,13 +408,13 @@ static int loapic_device_ctrl(const struct device *port,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) { if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
ret = loapic_suspend(port); ret = loapic_suspend(port);
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { } else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = loapic_resume(port); ret = loapic_resume(port);
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = loapic_device_power_state; *((uint32_t *)context) = loapic_device_power_state;
} }

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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
return 0; return 0;
@ -181,11 +181,11 @@ static int led_pwm_pm_control(const struct device *dev, uint32_t ctrl_command,
int err; int err;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
err = led_pwm_pm_get_state(dev, context); err = led_pwm_pm_get_state(dev, context);
break; break;
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
err = led_pwm_pm_set_state(dev, *((uint32_t *)context)); err = led_pwm_pm_set_state(dev, *((uint32_t *)context));
break; break;

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 = device_set_power_state(ictx.mdm_ctx.uart_dev, rc = device_set_power_state(ictx.mdm_ctx.uart_dev,
DEVICE_PM_OFF_STATE, NULL, NULL); PM_DEVICE_OFF_STATE, 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 = device_set_power_state(ictx.mdm_ctx.uart_dev, rc = device_set_power_state(ictx.mdm_ctx.uart_dev,
DEVICE_PM_ACTIVE_STATE, NULL, NULL); PM_DEVICE_ACTIVE_STATE, 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 DEVICE_PM_LOW_POWER_STATE #ifdef PM_DEVICE_LOW_POWER_STATE
device_set_power_state(ctx->uart_dev, DEVICE_PM_LOW_POWER_STATE, NULL, NULL); device_set_power_state(ctx->uart_dev, PM_DEVICE_LOW_POWER_STATE, 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 DEVICE_PM_LOW_POWER_STATE #ifdef PM_DEVICE_LOW_POWER_STATE
device_set_power_state(ctx->uart_dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL); device_set_power_state(ctx->uart_dev, PM_DEVICE_ACTIVE_STATE, 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 DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
err = pwm_nrfx_init(dev); err = pwm_nrfx_init(dev);
break; break;
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
case DEVICE_PM_FORCE_SUSPEND_STATE: case PM_DEVICE_FORCE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
if (current_state == DEVICE_PM_ACTIVE_STATE) { if (current_state == PM_DEVICE_ACTIVE_STATE) {
pwm_nrfx_uninit(dev); pwm_nrfx_uninit(dev);
} }
break; break;
@ -322,7 +322,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
{ {
int err = 0; int err = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != (*current_state)) { if (new_state != (*current_state)) {
@ -334,7 +334,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
} }
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = (*current_state); *((uint32_t *)context) = (*current_state);
} }
@ -348,7 +348,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
device_pm_cb cb, \ device_pm_cb cb, \
void *arg) \ void *arg) \
{ \ { \
static uint32_t current_state = DEVICE_PM_ACTIVE_STATE; \ static uint32_t current_state = PM_DEVICE_ACTIVE_STATE; \
int ret = 0; \ int ret = 0; \
ret = pwm_nrfx_pm_control(dev, ctrl_command, context, \ ret = pwm_nrfx_pm_control(dev, ctrl_command, context, \
&current_state); \ &current_state); \

View file

@ -416,10 +416,10 @@ static int apds9960_device_ctrl(const struct device *dev,
struct apds9960_data *data = dev->data; struct apds9960_data *data = dev->data;
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t device_pm_state = *(uint32_t *)context; uint32_t device_pm_state = *(uint32_t *)context;
if (device_pm_state == DEVICE_PM_ACTIVE_STATE) { if (device_pm_state == PM_DEVICE_ACTIVE_STATE) {
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,
@ -441,8 +441,8 @@ static int apds9960_device_ctrl(const struct device *dev,
} }
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = DEVICE_PM_ACTIVE_STATE; *((uint32_t *)context) = PM_DEVICE_ACTIVE_STATE;
} }
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 == DEVICE_PM_OFF_STATE) if (data->pm_state == PM_DEVICE_OFF_STATE)
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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
LOG_DBG("\"%s\" OK", dev->name); LOG_DBG("\"%s\" OK", dev->name);
return 0; return 0;
@ -398,19 +398,19 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
int ret = 0; int ret = 0;
/* Set power state */ /* Set power state */
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_pm_state = *((const uint32_t *)context); uint32_t new_pm_state = *((const uint32_t *)context);
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 == DEVICE_PM_OFF_STATE) { if (data->pm_state == PM_DEVICE_OFF_STATE) {
/* 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 == DEVICE_PM_OFF_STATE) { else if (new_pm_state == PM_DEVICE_OFF_STATE) {
/* Put the chip into sleep mode */ /* Put the chip into sleep mode */
ret = bme280_reg_write(dev, ret = bme280_reg_write(dev,
@ -429,7 +429,7 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
} }
/* Get power state */ /* Get power state */
else { else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }

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 != DEVICE_PM_ACTIVE_STATE) { if (data->device_power_state != PM_DEVICE_ACTIVE_STATE) {
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 != DEVICE_PM_ACTIVE_STATE) { if (bmp388->device_power_state != PM_DEVICE_ACTIVE_STATE) {
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 == DEVICE_PM_ACTIVE_STATE) { if (power_state == PM_DEVICE_ACTIVE_STATE) {
reg_val = BMP388_PWR_CTRL_MODE_NORMAL; reg_val = BMP388_PWR_CTRL_MODE_NORMAL;
} else if ((power_state == DEVICE_PM_SUSPEND_STATE) || } else if ((power_state == PM_DEVICE_SUSPEND_STATE) ||
(power_state == DEVICE_PM_OFF_STATE)) { (power_state == PM_DEVICE_OFF_STATE)) {
reg_val = BMP388_PWR_CTRL_MODE_SLEEP; reg_val = BMP388_PWR_CTRL_MODE_SLEEP;
} else { } else {
return 0; return 0;
@ -595,9 +595,9 @@ static int bmp388_device_ctrl(
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
ret = bmp388_set_power_state(dev, *((uint32_t *)context)); ret = bmp388_set_power_state(dev, *((uint32_t *)context));
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = bmp388_get_power_state(dev); *((uint32_t *)context) = bmp388_get_power_state(dev);
} }
@ -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 = DEVICE_PM_ACTIVE_STATE; bmp388->device_power_state = PM_DEVICE_ACTIVE_STATE;
#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 != DEVICE_PM_ACTIVE_STATE) { if (data->device_power_state != PM_DEVICE_ACTIVE_STATE) {
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 = DEVICE_PM_LOW_POWER_STATE; data->pm_state = PM_DEVICE_LOW_POWER_STATE;
#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 DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
if (data->pm_state == DEVICE_PM_OFF_STATE) { if (data->pm_state == PM_DEVICE_OFF_STATE) {
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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
break; break;
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
if (data->pm_state == DEVICE_PM_OFF_STATE) { if (data->pm_state == PM_DEVICE_OFF_STATE) {
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 = DEVICE_PM_LOW_POWER_STATE; data->pm_state = PM_DEVICE_LOW_POWER_STATE;
break; break;
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
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 = DEVICE_PM_OFF_STATE; data->pm_state = PM_DEVICE_OFF_STATE;
} else { } else {
LOG_ERR("SD pin not defined"); LOG_ERR("SD pin not defined");
ret = -EINVAL; ret = -EINVAL;
@ -549,13 +549,13 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
uint32_t new_state; uint32_t new_state;
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
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 DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
ret = fdc2x1x_set_pm_state(dev, new_state); ret = fdc2x1x_set_pm_state(dev, new_state);
break; break;
default: default:
@ -563,7 +563,7 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
ret = -EINVAL; ret = -EINVAL;
} }
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }
@ -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 != DEVICE_PM_ACTIVE_STATE) { if (data->pm_state != PM_DEVICE_ACTIVE_STATE) {
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 == DEVICE_PM_OFF_STATE) { if (drv_data->pm_state == PM_DEVICE_OFF_STATE) {
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 = DEVICE_PM_ACTIVE_STATE; lis2mdl->power_state = PM_DEVICE_ACTIVE_STATE;
#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 == DEVICE_PM_ACTIVE_STATE) { if (new_state == PM_DEVICE_ACTIVE_STATE) {
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 = DEVICE_PM_ACTIVE_STATE; lis2mdl->power_state = PM_DEVICE_ACTIVE_STATE;
LOG_DBG("State changed to active"); LOG_DBG("State changed to active");
} else { } else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
status = lis2mdl_operating_mode_set(lis2mdl->ctx, status = lis2mdl_operating_mode_set(lis2mdl->ctx,
LIS2MDL_POWER_DOWN); LIS2MDL_POWER_DOWN);
if (status) { if (status) {
@ -529,14 +529,14 @@ static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
uint32_t new_state; uint32_t new_state;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
new_state = *((const uint32_t *)context); new_state = *((const uint32_t *)context);
if (new_state != current_state) { if (new_state != current_state) {
status = lis2mdl_set_power_state(lis2mdl, config, status = lis2mdl_set_power_state(lis2mdl, config,
new_state); new_state);
} }
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = current_state; *((uint32_t *)context) = current_state;
break; break;
default: default:

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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#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 == DEVICE_PM_ACTIVE_STATE) { if (old_state == PM_DEVICE_ACTIVE_STATE) {
/* 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 == DEVICE_PM_OFF_STATE) { if (new_state == PM_DEVICE_OFF_STATE) {
/* device must be uninitialized */ /* device must be uninitialized */
nrfx_qdec_uninit(); nrfx_qdec_uninit();
} }
if (new_state == DEVICE_PM_ACTIVE_STATE) { if (new_state == PM_DEVICE_ACTIVE_STATE) {
qdec_nrfx_gpio_ctrl(true); qdec_nrfx_gpio_ctrl(true);
nrfx_qdec_enable(); nrfx_qdec_enable();
} }
@ -276,11 +276,11 @@ static int qdec_nrfx_pm_control(const struct device *dev,
LOG_DBG(""); LOG_DBG("");
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
err = qdec_nrfx_pm_get_state(data, context); err = qdec_nrfx_pm_get_state(data, context);
break; break;
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
err = qdec_nrfx_pm_set_state(data, *((uint32_t *)context)); err = qdec_nrfx_pm_set_state(data, *((uint32_t *)context));
break; break;

View file

@ -224,7 +224,7 @@ static int vcnl4040_device_ctrl(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t device_pm_state = *(uint32_t *)context; uint32_t device_pm_state = *(uint32_t *)context;
uint16_t ps_conf; uint16_t ps_conf;
@ -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 == DEVICE_PM_ACTIVE_STATE) { if (device_pm_state == PM_DEVICE_ACTIVE_STATE) {
/* Clear proximity shutdown */ /* Clear proximity shutdown */
ps_conf &= ~VCNL4040_PS_SD_MASK; ps_conf &= ~VCNL4040_PS_SD_MASK;
@ -274,8 +274,8 @@ static int vcnl4040_device_ctrl(const struct device *dev,
#endif #endif
} }
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) { } else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = DEVICE_PM_ACTIVE_STATE; *((uint32_t *)context) = PM_DEVICE_ACTIVE_STATE;
} }
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 == DEVICE_PM_ACTIVE_STATE) && if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
(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 == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
if (get_dev_data(dev)->pm_state == DEVICE_PM_ACTIVE_STATE) { if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) {
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
@ -449,7 +449,7 @@ static int uart_cc13xx_cc26xx_pm_control(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != get_dev_data(dev)->pm_state) { if (new_state != get_dev_data(dev)->pm_state) {
@ -457,7 +457,7 @@ static int uart_cc13xx_cc26xx_pm_control(const struct device *dev,
new_state); new_state);
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = get_dev_data(dev)->pm_state; *((uint32_t *)context) = get_dev_data(dev)->pm_state;
} }
@ -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 = DEVICE_PM_ACTIVE_STATE; \ get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; \
} while (0) } while (0)
#else #else
#define UART_CC13XX_CC26XX_INIT_PM_STATE #define UART_CC13XX_CC26XX_INIT_PM_STATE

View file

@ -432,8 +432,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 == DEVICE_PM_LOW_POWER_STATE || if (next_state == PM_DEVICE_LOW_POWER_STATE ||
next_state == DEVICE_PM_SUSPEND_STATE) { next_state == PM_DEVICE_SUSPEND_STATE) {
/* /*
* 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.
@ -454,10 +454,10 @@ static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
int ret = 0; int ret = 0;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
ret = uart_npcx_set_power_state(dev, *((uint32_t *)context)); ret = uart_npcx_set_power_state(dev, *((uint32_t *)context));
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
ret = uart_npcx_get_power_state(dev, (uint32_t *)context); ret = uart_npcx_get_power_state(dev, (uint32_t *)context);
break; break;
default: default:

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 == DEVICE_PM_ACTIVE_STATE) { if (new_state == PM_DEVICE_ACTIVE_STATE) {
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 == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
nrf_uart_disable(uart0_addr); nrf_uart_disable(uart0_addr);
uart_nrfx_pins_enable(dev, false); uart_nrfx_pins_enable(dev, false);
} }
@ -1160,9 +1160,9 @@ static int uart_nrfx_pm_control(const struct device *dev,
uint32_t ctrl_command, uint32_t ctrl_command,
void *context, device_pm_cb cb, void *arg) void *context, device_pm_cb cb, void *arg)
{ {
static uint32_t current_state = DEVICE_PM_ACTIVE_STATE; static uint32_t current_state = PM_DEVICE_ACTIVE_STATE;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != current_state) { if (new_state != current_state) {
@ -1170,7 +1170,7 @@ static int uart_nrfx_pm_control(const struct device *dev,
current_state = new_state; current_state = new_state;
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = current_state; *((uint32_t *)context) = current_state;
} }

View file

@ -1376,7 +1376,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 != DEVICE_PM_ACTIVE_STATE) { if (data->pm_state != PM_DEVICE_ACTIVE_STATE) {
return; return;
} }
#endif #endif
@ -1669,7 +1669,7 @@ static int uarte_instance_init(const struct device *dev,
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
data->pm_state = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
if (get_dev_config(dev)->flags & UARTE_CFG_FLAG_PPI_ENDTX) { if (get_dev_config(dev)->flags & UARTE_CFG_FLAG_PPI_ENDTX) {
@ -1773,7 +1773,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 == DEVICE_PM_ACTIVE_STATE) { if (new_state == PM_DEVICE_ACTIVE_STATE) {
uarte_nrfx_pins_enable(dev, true); uarte_nrfx_pins_enable(dev, true);
nrf_uarte_enable(uarte); nrf_uarte_enable(uarte);
@ -1801,14 +1801,14 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
#endif #endif
} }
} else { } else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
/* 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 != DEVICE_PM_ACTIVE_STATE) { if (data->pm_state != PM_DEVICE_ACTIVE_STATE) {
return; return;
} }
@ -1867,14 +1867,14 @@ static int uarte_nrfx_pm_control(const struct device *dev,
{ {
struct uarte_nrfx_data *data = get_dev_data(dev); struct uarte_nrfx_data *data = get_dev_data(dev);
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
uarte_nrfx_set_power_state(dev, new_state); uarte_nrfx_set_power_state(dev, new_state);
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }

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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
#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 != DEVICE_PM_ACTIVE_STATE) { if (new_state != PM_DEVICE_ACTIVE_STATE) {
#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) {
@ -1466,14 +1466,14 @@ static int uart_stm32_pm_control(const struct device *dev,
{ {
struct uart_stm32_data *data = DEV_DATA(dev); struct uart_stm32_data *data = DEV_DATA(dev);
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
uart_stm32_set_power_state(dev, new_state); uart_stm32_set_power_state(dev, new_state);
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }

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 == DEVICE_PM_ACTIVE_STATE) && if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
(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 == DEVICE_PM_LOW_POWER_STATE || __ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE || new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE); new_state == PM_DEVICE_OFF_STATE);
if (get_dev_data(dev)->pm_state == DEVICE_PM_ACTIVE_STATE) { if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) {
SSIDisable(get_dev_config(dev)->base); SSIDisable(get_dev_config(dev)->base);
/* /*
* Release power dependency * Release power dependency
@ -256,7 +256,7 @@ static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
{ {
int ret = 0; int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != get_dev_data(dev)->pm_state) { if (new_state != get_dev_data(dev)->pm_state) {
@ -264,7 +264,7 @@ static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
new_state); new_state);
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = get_dev_data(dev)->pm_state; *((uint32_t *)context) = get_dev_data(dev)->pm_state;
} }
@ -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 = DEVICE_PM_ACTIVE_STATE; \ get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; \
} 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 = DEVICE_PM_ACTIVE_STATE; dev_data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
return 0; return 0;
@ -292,21 +292,21 @@ static int spi_nrfx_pm_control(const struct device *dev,
struct spi_nrfx_data *data = get_dev_data(dev); struct spi_nrfx_data *data = get_dev_data(dev);
const struct spi_nrfx_config *config = get_dev_config(dev); const struct spi_nrfx_config *config = get_dev_config(dev);
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
switch (new_state) { switch (new_state) {
case DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
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 DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
if (data->pm_state == DEVICE_PM_ACTIVE_STATE) { if (data->pm_state == PM_DEVICE_ACTIVE_STATE) {
nrfx_spi_uninit(&config->spi); nrfx_spi_uninit(&config->spi);
} }
break; break;
@ -319,7 +319,7 @@ static int spi_nrfx_pm_control(const struct device *dev,
} }
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }

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 = DEVICE_PM_ACTIVE_STATE; data->pm_state = PM_DEVICE_ACTIVE_STATE;
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE; get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif #endif
return 0; return 0;
@ -340,21 +340,21 @@ static int spim_nrfx_pm_control(const struct device *dev,
struct spi_nrfx_data *data = get_dev_data(dev); struct spi_nrfx_data *data = get_dev_data(dev);
const struct spi_nrfx_config *config = get_dev_config(dev); const struct spi_nrfx_config *config = get_dev_config(dev);
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) { if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context); uint32_t new_state = *((const uint32_t *)context);
if (new_state != data->pm_state) { if (new_state != data->pm_state) {
switch (new_state) { switch (new_state) {
case DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
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 DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
if (data->pm_state == DEVICE_PM_ACTIVE_STATE) { if (data->pm_state == PM_DEVICE_ACTIVE_STATE) {
nrfx_spim_uninit(&config->spim); nrfx_spim_uninit(&config->spim);
} }
break; break;
@ -367,7 +367,7 @@ static int spim_nrfx_pm_control(const struct device *dev,
} }
} }
} else { } else {
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE); __ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
*((uint32_t *)context) = data->pm_state; *((uint32_t *)context) = data->pm_state;
} }

View file

@ -663,7 +663,7 @@ static inline int device_set_power_state(const struct device *dev,
return -ENOSYS; return -ENOSYS;
} }
return dev->device_pm_control(dev, DEVICE_PM_SET_POWER_STATE, return dev->device_pm_control(dev, PM_DEVICE_SET_POWER_STATE,
&device_power_state, cb, arg); &device_power_state, cb, arg);
} }
@ -687,7 +687,7 @@ static inline int device_get_power_state(const struct device *dev,
return -ENOSYS; return -ENOSYS;
} }
return dev->device_pm_control(dev, DEVICE_PM_GET_POWER_STATE, return dev->device_pm_control(dev, PM_DEVICE_GET_POWER_STATE,
device_power_state, NULL, NULL); device_power_state, NULL, NULL);
} }

View file

@ -24,24 +24,24 @@ extern "C" {
struct device; struct device;
/** @def DEVICE_PM_ACTIVE_STATE /** @def PM_DEVICE_ACTIVE_STATE
* *
* @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 DEVICE_PM_ACTIVE_STATE 1 #define PM_DEVICE_ACTIVE_STATE 1
/** @def DEVICE_PM_LOW_POWER_STATE /** @def PM_DEVICE_LOW_POWER_STATE
* *
* @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 DEVICE_PM_LOW_POWER_STATE 2 #define PM_DEVICE_LOW_POWER_STATE 2
/** @def DEVICE_PM_SUSPEND_STATE /** @def PM_DEVICE_SUSPEND_STATE
* *
* @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 DEVICE_PM_SUSPEND_STATE 3 #define PM_DEVICE_SUSPEND_STATE 3
/** @def DEVICE_PM_FORCE_SUSPEND_STATE /** @def PM_DEVICE_FORCE_SUSPEND_STATE
* *
* @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 DEVICE_PM_FORCE_SUSPEND_STATE 4 #define PM_DEVICE_FORCE_SUSPEND_STATE 4
/** @def DEVICE_PM_OFF_STATE /** @def PM_DEVICE_OFF_STATE
* *
* @brief device is in OFF power state * @brief device is in OFF power state
* *
@ -71,11 +71,11 @@ 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 DEVICE_PM_OFF_STATE 5 #define PM_DEVICE_OFF_STATE 5
/* Constants defining support device power commands */ /* Constants defining support device power commands */
#define DEVICE_PM_SET_POWER_STATE 1 #define PM_DEVICE_SET_POWER_STATE 1
#define DEVICE_PM_GET_POWER_STATE 2 #define PM_DEVICE_GET_POWER_STATE 2
typedef void (*device_pm_cb)(const struct device *dev, typedef void (*device_pm_cb)(const struct device *dev,
int status, void *context, void *arg); int status, void *context, void *arg);
@ -108,7 +108,7 @@ struct device_pm {
/** Bit position in device_pm::atomic_flags that records whether the /** Bit position in device_pm::atomic_flags that records whether the
* device is busy. * device is busy.
*/ */
#define DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT 0 #define PM_DEVICE_ATOMIC_FLAGS_BUSY_BIT 0
/** /**
* @brief Get name of device PM state * @brief Get name of device PM state

View file

@ -199,7 +199,7 @@ int device_any_busy_check(void)
while (dev < __device_end) { while (dev < __device_end) {
if (atomic_test_bit(&dev->pm->atomic_flags, if (atomic_test_bit(&dev->pm->atomic_flags,
DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT)) { PM_DEVICE_ATOMIC_FLAGS_BUSY_BIT)) {
return -EBUSY; return -EBUSY;
} }
++dev; ++dev;
@ -211,7 +211,7 @@ int device_any_busy_check(void)
int device_busy_check(const struct device *dev) int device_busy_check(const struct device *dev)
{ {
if (atomic_test_bit(&dev->pm->atomic_flags, if (atomic_test_bit(&dev->pm->atomic_flags,
DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT)) { PM_DEVICE_ATOMIC_FLAGS_BUSY_BIT)) {
return -EBUSY; return -EBUSY;
} }
return 0; return 0;
@ -223,7 +223,7 @@ void device_busy_set(const struct device *dev)
{ {
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
atomic_set_bit(&dev->pm->atomic_flags, atomic_set_bit(&dev->pm->atomic_flags,
DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT); PM_DEVICE_ATOMIC_FLAGS_BUSY_BIT);
#else #else
ARG_UNUSED(dev); ARG_UNUSED(dev);
#endif #endif
@ -233,7 +233,7 @@ void device_busy_clear(const struct device *dev)
{ {
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
atomic_clear_bit(&dev->pm->atomic_flags, atomic_clear_bit(&dev->pm->atomic_flags,
DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT); PM_DEVICE_ATOMIC_FLAGS_BUSY_BIT);
#else #else
ARG_UNUSED(dev); ARG_UNUSED(dev);
#endif #endif

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 = device_set_power_state(cons, DEVICE_PM_LOW_POWER_STATE, NULL, NULL); rc = device_set_power_state(cons, PM_DEVICE_LOW_POWER_STATE, NULL, NULL);
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC); k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
rc = device_set_power_state(cons, DEVICE_PM_ACTIVE_STATE, NULL, NULL); rc = device_set_power_state(cons, PM_DEVICE_ACTIVE_STATE, 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 = device_set_power_state(cons, DEVICE_PM_LOW_POWER_STATE, NULL, NULL); rc = device_set_power_state(cons, PM_DEVICE_LOW_POWER_STATE, NULL, NULL);
k_sleep(K_SECONDS(SLEEP_S)); k_sleep(K_SECONDS(SLEEP_S));
rc = device_set_power_state(cons, DEVICE_PM_ACTIVE_STATE, NULL, NULL); rc = device_set_power_state(cons, PM_DEVICE_ACTIVE_STATE, 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 = device_set_power_state(flash_dev, DEVICE_PM_LOW_POWER_STATE, err = device_set_power_state(flash_dev, PM_DEVICE_LOW_POWER_STATE,
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 = DEVICE_PM_LOW_POWER_STATE; p_state = PM_DEVICE_LOW_POWER_STATE;
device_set_power_state(dev, p_state, NULL, NULL); device_set_power_state(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 = DEVICE_PM_ACTIVE_STATE; p_state = PM_DEVICE_ACTIVE_STATE;
device_set_power_state(dev, p_state, NULL, NULL); device_set_power_state(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 DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
printk("Enter ACTIVE_STATE "); printk("Enter ACTIVE_STATE ");
break; break;
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
printk("Enter LOW_POWER_STATE "); printk("Enter LOW_POWER_STATE ");
break; break;
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
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 = DEVICE_PM_LOW_POWER_STATE; p_state = PM_DEVICE_LOW_POWER_STATE;
device_set_power_state(dev, p_state, pm_cb, NULL); device_set_power_state(dev, p_state, pm_cb, NULL);
p_state = DEVICE_PM_OFF_STATE; p_state = PM_DEVICE_OFF_STATE;
device_set_power_state(dev, p_state, pm_cb, NULL); device_set_power_state(dev, p_state, pm_cb, NULL);
p_state = DEVICE_PM_ACTIVE_STATE; p_state = PM_DEVICE_ACTIVE_STATE;
device_set_power_state(dev, p_state, pm_cb, NULL); device_set_power_state(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 = DEVICE_PM_OFF_STATE; p_state = PM_DEVICE_OFF_STATE;
device_set_power_state(dev, p_state, pm_cb, NULL); device_set_power_state(dev, p_state, pm_cb, NULL);
k_sleep(K_MSEC(2000)); k_sleep(K_MSEC(2000));
p_state = DEVICE_PM_ACTIVE_STATE; p_state = PM_DEVICE_ACTIVE_STATE;
device_set_power_state(dev, p_state, pm_cb, NULL); device_set_power_state(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

@ -41,7 +41,7 @@ static int dummy_open(const struct device *dev)
async_evt.state = K_POLL_STATE_NOT_READY; async_evt.state = K_POLL_STATE_NOT_READY;
k_poll_signal_reset(&dev->pm->signal); k_poll_signal_reset(&dev->pm->signal);
if (result == DEVICE_PM_ACTIVE_STATE) { if (result == PM_DEVICE_ACTIVE_STATE) {
printk("Dummy device resumed\n"); printk("Dummy device resumed\n");
ret = 0; ret = 0;
} else { } else {
@ -101,7 +101,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 = DEVICE_PM_SUSPEND_STATE; device_power_state = PM_DEVICE_SUSPEND_STATE;
return 0; return 0;
} }
@ -109,7 +109,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 = DEVICE_PM_ACTIVE_STATE; device_power_state = PM_DEVICE_ACTIVE_STATE;
return 0; return 0;
} }
@ -121,14 +121,14 @@ static int dummy_device_pm_ctrl(const struct device *dev,
int ret = 0; int ret = 0;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = dummy_resume_from_suspend(dev); ret = dummy_resume_from_suspend(dev);
} else { } else {
ret = dummy_suspend(dev); ret = dummy_suspend(dev);
} }
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = dummy_get_power_state(dev); *((uint32_t *)context) = dummy_get_power_state(dev);
break; break;
default: default:
@ -156,7 +156,7 @@ int dummy_init(const struct device *dev)
} }
pm_device_enable(dev); pm_device_enable(dev);
device_power_state = DEVICE_PM_ACTIVE_STATE; device_power_state = PM_DEVICE_ACTIVE_STATE;
k_poll_event_init(&async_evt, K_POLL_TYPE_SIGNAL, k_poll_event_init(&async_evt, K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY, &dev->pm->signal); K_POLL_MODE_NOTIFY_ONLY, &dev->pm->signal);

View file

@ -32,7 +32,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 = DEVICE_PM_SUSPEND_STATE; parent_power_state = PM_DEVICE_SUSPEND_STATE;
return 0; return 0;
} }
@ -40,7 +40,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 = DEVICE_PM_ACTIVE_STATE; parent_power_state = PM_DEVICE_ACTIVE_STATE;
return 0; return 0;
} }
@ -52,14 +52,14 @@ static int dummy_parent_pm_ctrl(const struct device *dev,
int ret = 0; int ret = 0;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = dummy_resume_from_suspend(dev); ret = dummy_resume_from_suspend(dev);
} else { } else {
ret = dummy_suspend(dev); ret = dummy_suspend(dev);
} }
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = dummy_get_power_state(dev); *((uint32_t *)context) = dummy_get_power_state(dev);
break; break;
default: default:
@ -78,7 +78,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 = DEVICE_PM_ACTIVE_STATE; parent_power_state = PM_DEVICE_ACTIVE_STATE;
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 = device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE, ret = device_set_power_state(dev, PM_DEVICE_SUSPEND_STATE,
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 = device_set_power_state(dev, DEVICE_PM_ACTIVE_STATE, ret = device_set_power_state(dev, PM_DEVICE_ACTIVE_STATE,
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

@ -87,17 +87,17 @@ static int _pm_devices(uint32_t state)
int pm_suspend_devices(void) int pm_suspend_devices(void)
{ {
return _pm_devices(DEVICE_PM_SUSPEND_STATE); return _pm_devices(PM_DEVICE_SUSPEND_STATE);
} }
int pm_low_power_devices(void) int pm_low_power_devices(void)
{ {
return _pm_devices(DEVICE_PM_LOW_POWER_STATE); return _pm_devices(PM_DEVICE_LOW_POWER_STATE);
} }
int pm_force_suspend_devices(void) int pm_force_suspend_devices(void)
{ {
return _pm_devices(DEVICE_PM_FORCE_SUSPEND_STATE); return _pm_devices(PM_DEVICE_FORCE_SUSPEND_STATE);
} }
void pm_resume_devices(void) void pm_resume_devices(void)
@ -109,7 +109,7 @@ void pm_resume_devices(void)
device_idx_t idx = pm_devices[pmi]; device_idx_t idx = pm_devices[pmi];
device_set_power_state(&all_devices[idx], device_set_power_state(&all_devices[idx],
DEVICE_PM_ACTIVE_STATE, PM_DEVICE_ACTIVE_STATE,
NULL, NULL); NULL, NULL);
++pmi; ++pmi;
} }
@ -168,15 +168,15 @@ void pm_create_device_list(void)
const char *device_pm_state_str(uint32_t state) const char *device_pm_state_str(uint32_t state)
{ {
switch (state) { switch (state) {
case DEVICE_PM_ACTIVE_STATE: case PM_DEVICE_ACTIVE_STATE:
return "active"; return "active";
case DEVICE_PM_LOW_POWER_STATE: case PM_DEVICE_LOW_POWER_STATE:
return "low power"; return "low power";
case DEVICE_PM_SUSPEND_STATE: case PM_DEVICE_SUSPEND_STATE:
return "suspend"; return "suspend";
case DEVICE_PM_FORCE_SUSPEND_STATE: case PM_DEVICE_FORCE_SUSPEND_STATE:
return "force suspend"; return "force suspend";
case DEVICE_PM_OFF_STATE: case PM_DEVICE_OFF_STATE:
return "off"; return "off";
default: default:
return ""; return "";

View file

@ -16,15 +16,15 @@ LOG_MODULE_DECLARE(power);
/* Device PM states */ /* Device PM states */
enum device_pm_state { enum device_pm_state {
DEVICE_PM_STATE_ACTIVE = 1, PM_DEVICE_STATE_ACTIVE = 1,
DEVICE_PM_STATE_SUSPENDED, PM_DEVICE_STATE_SUSPENDED,
DEVICE_PM_STATE_SUSPENDING, PM_DEVICE_STATE_SUSPENDING,
DEVICE_PM_STATE_RESUMING, PM_DEVICE_STATE_RESUMING,
}; };
/* Device PM request type */ /* Device PM request type */
#define DEVICE_PM_SYNC (0 << 0) #define PM_DEVICE_SYNC (0 << 0)
#define DEVICE_PM_ASYNC (1 << 0) #define PM_DEVICE_ASYNC (1 << 0)
static void device_pm_callback(const struct device *dev, static void device_pm_callback(const struct device *dev,
int retval, void *context, void *arg) int retval, void *context, void *arg)
@ -32,12 +32,12 @@ static void device_pm_callback(const struct device *dev,
__ASSERT(retval == 0, "Device set power state failed"); __ASSERT(retval == 0, "Device set power state failed");
/* Set the fsm_state */ /* Set the fsm_state */
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
atomic_set(&dev->pm->fsm_state, atomic_set(&dev->pm->fsm_state,
DEVICE_PM_STATE_ACTIVE); PM_DEVICE_STATE_ACTIVE);
} else { } else {
atomic_set(&dev->pm->fsm_state, atomic_set(&dev->pm->fsm_state,
DEVICE_PM_STATE_SUSPENDED); PM_DEVICE_STATE_SUSPENDED);
} }
k_work_submit(&dev->pm->work); k_work_submit(&dev->pm->work);
@ -52,34 +52,34 @@ static void pm_work_handler(struct k_work *work)
uint8_t pm_state; uint8_t pm_state;
switch (atomic_get(&dev->pm->fsm_state)) { switch (atomic_get(&dev->pm->fsm_state)) {
case DEVICE_PM_STATE_ACTIVE: 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->fsm_state, atomic_set(&dev->pm->fsm_state,
DEVICE_PM_STATE_SUSPENDING); PM_DEVICE_STATE_SUSPENDING);
ret = device_set_power_state(dev, ret = device_set_power_state(dev,
DEVICE_PM_SUSPEND_STATE, PM_DEVICE_SUSPEND_STATE,
device_pm_callback, NULL); device_pm_callback, NULL);
} else { } else {
pm_state = DEVICE_PM_ACTIVE_STATE; pm_state = PM_DEVICE_ACTIVE_STATE;
goto fsm_out; goto fsm_out;
} }
break; break;
case DEVICE_PM_STATE_SUSPENDED: case PM_DEVICE_STATE_SUSPENDED:
if ((atomic_get(&dev->pm->usage) > 0) || if ((atomic_get(&dev->pm->usage) > 0) ||
!dev->pm->enable) { !dev->pm->enable) {
atomic_set(&dev->pm->fsm_state, atomic_set(&dev->pm->fsm_state,
DEVICE_PM_STATE_RESUMING); PM_DEVICE_STATE_RESUMING);
ret = device_set_power_state(dev, ret = device_set_power_state(dev,
DEVICE_PM_ACTIVE_STATE, PM_DEVICE_ACTIVE_STATE,
device_pm_callback, NULL); device_pm_callback, NULL);
} else { } else {
pm_state = DEVICE_PM_SUSPEND_STATE; pm_state = PM_DEVICE_SUSPEND_STATE;
goto fsm_out; goto fsm_out;
} }
break; break;
case DEVICE_PM_STATE_SUSPENDING: case PM_DEVICE_STATE_SUSPENDING:
case DEVICE_PM_STATE_RESUMING: 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:
@ -99,11 +99,11 @@ static int pm_device_request(const struct device *dev,
{ {
int result, signaled = 0; int result, signaled = 0;
__ASSERT((target_state == DEVICE_PM_ACTIVE_STATE) || __ASSERT((target_state == PM_DEVICE_ACTIVE_STATE) ||
(target_state == DEVICE_PM_SUSPEND_STATE), (target_state == PM_DEVICE_SUSPEND_STATE),
"Invalid device PM state requested"); "Invalid device PM state requested");
if (target_state == DEVICE_PM_ACTIVE_STATE) { if (target_state == PM_DEVICE_ACTIVE_STATE) {
if (atomic_inc(&dev->pm->usage) < 0) { if (atomic_inc(&dev->pm->usage) < 0) {
return 0; return 0;
} }
@ -116,7 +116,7 @@ static int pm_device_request(const struct device *dev,
k_work_submit(&dev->pm->work); k_work_submit(&dev->pm->work);
/* Return in case of Async request */ /* Return in case of Async request */
if (pm_flags & DEVICE_PM_ASYNC) { if (pm_flags & PM_DEVICE_ASYNC) {
return 0; return 0;
} }
@ -137,23 +137,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,
DEVICE_PM_ACTIVE_STATE, DEVICE_PM_ASYNC); PM_DEVICE_ACTIVE_STATE, 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, DEVICE_PM_ACTIVE_STATE, 0); return pm_device_request(dev, PM_DEVICE_ACTIVE_STATE, 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,
DEVICE_PM_SUSPEND_STATE, DEVICE_PM_ASYNC); PM_DEVICE_SUSPEND_STATE, 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, DEVICE_PM_SUSPEND_STATE, 0); return pm_device_request(dev, PM_DEVICE_SUSPEND_STATE, 0);
} }
void pm_device_enable(const struct device *dev) void pm_device_enable(const struct device *dev)
@ -168,7 +168,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->fsm_state, atomic_set(&dev->pm->fsm_state,
DEVICE_PM_STATE_SUSPENDED); PM_DEVICE_STATE_SUSPENDED);
k_work_init(&dev->pm->work, pm_work_handler); k_work_init(&dev->pm->work, pm_work_handler);
} else { } else {
k_work_submit(&dev->pm->work); k_work_submit(&dev->pm->work);

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 = DEVICE_PM_ACTIVE_STATE; uint32_t st = PM_DEVICE_ACTIVE_STATE;
int err = device_get_power_state(dev, &st); int err = device_get_power_state(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 DEVICE_PM_ACTIVE_STATE */ /* Set device state to PM_DEVICE_ACTIVE_STATE */
ret = device_set_power_state(dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL); ret = device_set_power_state(dev, PM_DEVICE_ACTIVE_STATE, 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 = device_get_power_state(dev, &device_power_state); ret = device_get_power_state(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 == DEVICE_PM_ACTIVE_STATE), zassert_true((device_power_state == PM_DEVICE_ACTIVE_STATE),
"Error power status"); "Error power status");
/* Set device state to DEVICE_PM_FORCE_SUSPEND_STATE */ /* Set device state to PM_DEVICE_FORCE_SUSPEND_STATE */
ret = device_set_power_state(dev, ret = device_set_power_state(dev,
DEVICE_PM_FORCE_SUSPEND_STATE, NULL, NULL); PM_DEVICE_FORCE_SUSPEND_STATE, NULL, NULL);
zassert_true((ret == 0), "Unable to force suspend device"); zassert_true((ret == 0), "Unable to force suspend device");
ret = device_get_power_state(dev, &device_power_state); ret = device_get_power_state(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 == DEVICE_PM_ACTIVE_STATE), zassert_true((device_power_state == PM_DEVICE_ACTIVE_STATE),
"Error power status"); "Error power status");
} }
#else #else

View file

@ -27,13 +27,13 @@ static int fake_dev_pm_control(const struct device *dev, uint32_t command,
struct fake_dev_context *ctx = dev->data; struct fake_dev_context *ctx = dev->data;
int ret = 0; int ret = 0;
if (command == DEVICE_PM_SET_POWER_STATE) { if (command == PM_DEVICE_SET_POWER_STATE) {
if (*(uint32_t *)context == DEVICE_PM_SUSPEND_STATE) { if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
ret = net_if_suspend(ctx->iface); ret = net_if_suspend(ctx->iface);
if (ret == -EBUSY) { if (ret == -EBUSY) {
goto out; goto out;
} }
} else if (*(uint32_t *)context == DEVICE_PM_ACTIVE_STATE) { } else if (*(uint32_t *)context == PM_DEVICE_ACTIVE_STATE) {
ret = net_if_resume(ctx->iface); ret = net_if_resume(ctx->iface);
} }
} else { } else {
@ -149,14 +149,14 @@ void test_pm(void)
*/ */
k_yield(); k_yield();
ret = device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE, ret = device_set_power_state(dev, PM_DEVICE_SUSPEND_STATE,
NULL, NULL); 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 = device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE, ret = device_set_power_state(dev, PM_DEVICE_SUSPEND_STATE,
NULL, NULL); NULL, NULL);
zassert_true(ret == -EALREADY, "Could change state"); zassert_true(ret == -EALREADY, "Could change state");
@ -167,13 +167,13 @@ 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 = device_set_power_state(dev, DEVICE_PM_ACTIVE_STATE, ret = device_set_power_state(dev, PM_DEVICE_ACTIVE_STATE,
NULL, NULL); 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 = device_set_power_state(dev, DEVICE_PM_ACTIVE_STATE, ret = device_set_power_state(dev, PM_DEVICE_ACTIVE_STATE,
NULL, NULL); NULL, NULL);
zassert_true(ret == -EALREADY, "Could change state"); zassert_true(ret == -EALREADY, "Could change state");

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 = DEVICE_PM_SUSPEND_STATE; device_power_state = PM_DEVICE_SUSPEND_STATE;
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 = DEVICE_PM_ACTIVE_STATE; device_power_state = PM_DEVICE_ACTIVE_STATE;
return 0; return 0;
} }
@ -45,14 +45,14 @@ static int dummy_device_pm_ctrl(const struct device *dev,
int ret = 0; int ret = 0;
switch (ctrl_command) { switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE: case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = dummy_resume_from_suspend(dev); ret = dummy_resume_from_suspend(dev);
} else { } else {
ret = dummy_suspend(dev); ret = dummy_suspend(dev);
} }
break; break;
case DEVICE_PM_GET_POWER_STATE: case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = dummy_get_power_state(dev); *((uint32_t *)context) = dummy_get_power_state(dev);
break; break;
default: default:

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 */
device_get_power_state(dev, &device_power_state); device_get_power_state(dev, &device_power_state);
zassert_false(device_power_state == DEVICE_PM_ACTIVE_STATE, NULL); zassert_false(device_power_state == PM_DEVICE_ACTIVE_STATE, 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 */
device_get_power_state(dev, &device_power_state); device_get_power_state(dev, &device_power_state);
zassert_false(device_power_state == DEVICE_PM_ACTIVE_STATE, NULL); zassert_false(device_power_state == PM_DEVICE_ACTIVE_STATE, 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*/
device_get_power_state(dev, &device_power_state); device_get_power_state(dev, &device_power_state);
zassert_equal(device_power_state, DEVICE_PM_ACTIVE_STATE, NULL); zassert_equal(device_power_state, PM_DEVICE_ACTIVE_STATE, 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;
device_get_power_state(dev, &device_power_state); device_get_power_state(dev, &device_power_state);
zassert_equal(device_power_state, DEVICE_PM_ACTIVE_STATE, NULL); zassert_equal(device_power_state, PM_DEVICE_ACTIVE_STATE, NULL);
api->close(dev); api->close(dev);
device_get_power_state(dev, &device_power_state); device_get_power_state(dev, &device_power_state);
zassert_equal(device_power_state, DEVICE_PM_SUSPEND_STATE, NULL); zassert_equal(device_power_state, PM_DEVICE_SUSPEND_STATE, 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);
} }