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:
:code:`DEVICE_PM_ACTIVE_STATE`
:code:`PM_DEVICE_ACTIVE_STATE`
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.
:code:`DEVICE_PM_SUSPEND_STATE`
:code:`PM_DEVICE_SUSPEND_STATE`
Most device context is lost by the hardware. Device drivers must save and
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
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.
The supported PM control commands are:
* DEVICE_PM_SET_POWER_STATE
* DEVICE_PM_GET_POWER_STATE
* PM_DEVICE_SET_POWER_STATE
* PM_DEVICE_GET_POWER_STATE
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);
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
----------------------
@ -308,7 +308,7 @@ Device Get 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
device driver with DEVICE_PM_GET_POWER_STATE command.
device driver with PM_DEVICE_GET_POWER_STATE command.
Busy Status Indication
======================

View file

@ -476,7 +476,7 @@ static int st7735r_init(const struct device *dev)
}
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
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;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = st7735r_exit_sleep(data);
if (ret < 0) {
return ret;
}
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
} else {
ret = st7735r_enter_sleep(data);
if (ret < 0) {
return ret;
}
data->pm_state = DEVICE_PM_LOW_POWER_STATE;
data->pm_state = PM_DEVICE_LOW_POWER_STATE;
}
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = data->pm_state;
break;

View file

@ -376,7 +376,7 @@ static int st7789v_init(const struct device *dev)
#endif
#ifdef CONFIG_PM_DEVICE
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
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;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
st7789v_exit_sleep(data);
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
ret = 0;
} else {
st7789v_enter_sleep(data);
data->pm_state = DEVICE_PM_LOW_POWER_STATE;
data->pm_state = PM_DEVICE_LOW_POWER_STATE;
ret = 0;
}
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = data->pm_state;
break;
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);
int ret = 0;
if ((new_state == DEVICE_PM_ACTIVE_STATE) &&
if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
(new_state != data->pm_state)) {
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
start_trng(data);
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_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);
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);
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);
if (new_state != data->pm_state) {
@ -307,7 +307,7 @@ static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
new_state);
}
} 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;
}
@ -324,7 +324,7 @@ static int entropy_cc13xx_cc26xx_init(const struct device *dev)
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
#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
/* Initialize driver data */

View file

@ -198,8 +198,8 @@ static int eth_mcux_device_pm_control(const struct device *dev,
goto out;
}
if (command == DEVICE_PM_SET_POWER_STATE) {
if (*(uint32_t *)context == DEVICE_PM_SUSPEND_STATE) {
if (command == PM_DEVICE_SET_POWER_STATE) {
if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
LOG_DBG("Suspending");
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);
clock_control_off(eth_ctx->clock_dev,
(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");
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);
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);
if (new_state != dev_data->pm_state) {
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
acquire(dev);
power_down_op(dev, CMD_EXIT_DPD,
dev_config->t_exit_dpd);
release(dev);
break;
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE:
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_SUSPEND_STATE:
case PM_DEVICE_OFF_STATE:
acquire(dev);
power_down_op(dev,
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;
}
} 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;
}
@ -647,7 +647,7 @@ static const struct flash_driver_api spi_flash_at45_api = {
static struct spi_flash_at45_data inst_##idx##_data = { \
.lock = Z_SEM_INITIALIZER(inst_##idx##_data.lock, 1, 1), \
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 = { \
.spi_bus = DT_INST_BUS_LABEL(idx), \

View file

@ -37,9 +37,9 @@ LOG_MODULE_REGISTER(spi_nor, CONFIG_FLASH_LOG_LEVEL);
* Kconfig option.
*
* When mapped to the Zephyr Device Power Management states:
* * DEVICE_PM_ACTIVE_STATE covers both active and standby modes;
* * DEVICE_PM_LOW_POWER_STATE, DEVICE_PM_SUSPEND_STATE, and
* DEVICE_PM_OFF_STATE all correspond to deep-power-down mode.
* * PM_DEVICE_ACTIVE_STATE covers both active and standby modes;
* * PM_DEVICE_LOW_POWER_STATE, PM_DEVICE_SUSPEND_STATE, and
* PM_DEVICE_OFF_STATE all correspond to deep-power-down mode.
*/
#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)
{
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;
}
@ -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)
{
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;
}
@ -465,13 +465,13 @@ static int gpio_dw_device_ctrl(const struct device *port,
{
int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
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);
}
} 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);
}
@ -544,7 +544,7 @@ static int gpio_dw_initialize(const struct device *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;
}

View file

@ -333,7 +333,7 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
{
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)) {
Power_setDependency(PowerCC26XX_PERIPH_I2C0);
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;
}
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_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);
I2CMasterDisable(get_dev_config(dev)->base);
/* 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;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context);
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);
}
} 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;
}
@ -399,7 +399,7 @@ static int i2c_cc13xx_cc26xx_init(const struct device *dev)
int err;
#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
#ifdef CONFIG_PM

View file

@ -206,7 +206,7 @@ static int init_twi(const struct device *dev)
return -EBUSY;
}
#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
return 0;
@ -220,12 +220,12 @@ static int twi_nrfx_pm_control(const struct device *dev,
int ret = 0;
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);
if (new_state != pm_current_state) {
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
init_twi(dev);
if (get_dev_data(dev)->dev_config) {
i2c_nrfx_twi_configure(
@ -234,10 +234,10 @@ static int twi_nrfx_pm_control(const struct device *dev,
}
break;
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE:
if (pm_current_state == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_SUSPEND_STATE:
case PM_DEVICE_OFF_STATE:
if (pm_current_state == PM_DEVICE_ACTIVE_STATE) {
nrfx_twi_uninit(&get_dev_config(dev)->twi);
}
break;
@ -250,7 +250,7 @@ static int twi_nrfx_pm_control(const struct device *dev,
}
}
} 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;
}

View file

@ -256,7 +256,7 @@ static int init_twim(const struct device *dev)
}
#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
return 0;
@ -270,12 +270,12 @@ static int twim_nrfx_pm_control(const struct device *dev,
int ret = 0;
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);
if (new_state != pm_current_state) {
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
init_twim(dev);
if (get_dev_data(dev)->dev_config) {
i2c_nrfx_twim_configure(
@ -284,10 +284,10 @@ static int twim_nrfx_pm_control(const struct device *dev,
}
break;
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE:
if (pm_current_state != DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_SUSPEND_STATE:
case PM_DEVICE_OFF_STATE:
if (pm_current_state != PM_DEVICE_ACTIVE_STATE) {
break;
}
nrfx_twim_uninit(&get_dev_config(dev)->twim);
@ -301,7 +301,7 @@ static int twim_nrfx_pm_control(const struct device *dev,
}
}
} 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;
}

View file

@ -32,7 +32,7 @@ extern void *_VectorTable;
#define _ARC_V2_IRQ_VECT_BASE _ARC_V2_IRQ_VECT_BASE_S
#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 {
uint32_t irq_ctrl; /* Interrupt Context Saving Control Register. */
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_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;
}
@ -166,7 +166,7 @@ static int arc_v2_irq_unit_resume(const struct device *dev)
#endif
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;
}
@ -198,13 +198,13 @@ static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
int ret = 0;
unsigned int key = arch_irq_lock();
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
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);
}
} 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);
}

View file

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

View file

@ -63,7 +63,7 @@
#ifdef CONFIG_PM_DEVICE
#include <pm/device.h>
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
#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;
}
@ -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;
}
@ -408,13 +408,13 @@ static int loapic_device_ctrl(const struct device *port,
{
int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
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);
}
} 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;
}

View file

@ -120,7 +120,7 @@ static int led_pwm_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
struct led_pwm_data *data = DEV_DATA(dev);
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
return 0;
@ -181,11 +181,11 @@ static int led_pwm_pm_control(const struct device *dev, uint32_t ctrl_command,
int err;
switch (ctrl_command) {
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
err = led_pwm_pm_get_state(dev, context);
break;
case DEVICE_PM_SET_POWER_STATE:
case PM_DEVICE_SET_POWER_STATE:
err = led_pwm_pm_set_state(dev, *((uint32_t *)context));
break;

View file

@ -3490,7 +3490,7 @@ static void shutdown_uart(void)
HL7800_IO_DBG_LOG("Power OFF the UART");
uart_irq_rx_disable(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) {
LOG_ERR("Error disabling UART peripheral (%d)", rc);
}
@ -3507,7 +3507,7 @@ static void power_on_uart(void)
if (!ictx.uart_on) {
HL7800_IO_DBG_LOG("Power ON the UART");
rc = device_set_power_state(ictx.mdm_ctx.uart_dev,
DEVICE_PM_ACTIVE_STATE, NULL, NULL);
PM_DEVICE_ACTIVE_STATE, NULL, NULL);
if (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)
{
uart_irq_rx_disable(ctx->uart_dev);
#ifdef DEVICE_PM_LOW_POWER_STATE
device_set_power_state(ctx->uart_dev, DEVICE_PM_LOW_POWER_STATE, NULL, NULL);
#ifdef PM_DEVICE_LOW_POWER_STATE
device_set_power_state(ctx->uart_dev, PM_DEVICE_LOW_POWER_STATE, NULL, NULL);
#endif
return 0;
}
int mdm_receiver_wake(struct mdm_receiver_context *ctx)
{
#ifdef DEVICE_PM_LOW_POWER_STATE
device_set_power_state(ctx->uart_dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
#ifdef PM_DEVICE_LOW_POWER_STATE
device_set_power_state(ctx->uart_dev, PM_DEVICE_ACTIVE_STATE, NULL, NULL);
#endif
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;
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
err = pwm_nrfx_init(dev);
break;
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE:
case DEVICE_PM_FORCE_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE:
if (current_state == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_SUSPEND_STATE:
case PM_DEVICE_FORCE_SUSPEND_STATE:
case PM_DEVICE_OFF_STATE:
if (current_state == PM_DEVICE_ACTIVE_STATE) {
pwm_nrfx_uninit(dev);
}
break;
@ -322,7 +322,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
{
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);
if (new_state != (*current_state)) {
@ -334,7 +334,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
}
}
} 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);
}
@ -348,7 +348,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
device_pm_cb cb, \
void *arg) \
{ \
static uint32_t current_state = DEVICE_PM_ACTIVE_STATE; \
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE; \
int ret = 0; \
ret = pwm_nrfx_pm_control(dev, ctrl_command, context, \
&current_state); \

View file

@ -416,10 +416,10 @@ static int apds9960_device_ctrl(const struct device *dev,
struct apds9960_data *data = dev->data;
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;
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,
APDS9960_ENABLE_REG,
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) {
*((uint32_t *)context) = DEVICE_PM_ACTIVE_STATE;
} else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = PM_DEVICE_ACTIVE_STATE;
}
if (cb) {

View file

@ -183,7 +183,7 @@ static int bme280_sample_fetch(const struct device *dev,
#ifdef CONFIG_PM_DEVICE
/* 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;
#endif
@ -383,7 +383,7 @@ static int bme280_chip_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
/* Set power state to ACTIVE */
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
LOG_DBG("\"%s\" OK", dev->name);
return 0;
@ -398,19 +398,19 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
int ret = 0;
/* 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);
if (new_pm_state != data->pm_state) {
/* 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 */
ret = bme280_chip_init(dev);
}
/* 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 */
ret = bme280_reg_write(dev,
@ -429,7 +429,7 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
}
/* Get power state */
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;
}

View file

@ -313,7 +313,7 @@ static int bmp388_attr_set(const struct device *dev,
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
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;
}
#endif
@ -348,7 +348,7 @@ static int bmp388_sample_fetch(const struct device *dev,
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL);
#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;
}
#endif
@ -557,10 +557,10 @@ static int bmp388_set_power_state(const struct device *dev,
return 0;
}
if (power_state == DEVICE_PM_ACTIVE_STATE) {
if (power_state == PM_DEVICE_ACTIVE_STATE) {
reg_val = BMP388_PWR_CTRL_MODE_NORMAL;
} else if ((power_state == DEVICE_PM_SUSPEND_STATE) ||
(power_state == DEVICE_PM_OFF_STATE)) {
} else if ((power_state == PM_DEVICE_SUSPEND_STATE) ||
(power_state == PM_DEVICE_OFF_STATE)) {
reg_val = BMP388_PWR_CTRL_MODE_SLEEP;
} else {
return 0;
@ -595,9 +595,9 @@ static int bmp388_device_ctrl(
{
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));
} 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);
}
@ -672,7 +672,7 @@ static int bmp388_init(const struct device *dev)
}
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
bmp388->device_power_state = DEVICE_PM_ACTIVE_STATE;
bmp388->device_power_state = PM_DEVICE_ACTIVE_STATE;
#endif
/* Read calibration data */

View file

@ -92,7 +92,7 @@ int bmp388_trigger_set(
struct bmp388_data *data = DEV_DATA(dev);
#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;
}
#endif

View file

@ -424,7 +424,7 @@ static int fdc2x1x_reset(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
struct fdc2x1x_data *data = dev->data;
data->pm_state = DEVICE_PM_LOW_POWER_STATE;
data->pm_state = PM_DEVICE_LOW_POWER_STATE;
#endif
return ret;
@ -496,8 +496,8 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
const struct fdc2x1x_config *cfg = dev->config;
switch (pm_state) {
case DEVICE_PM_ACTIVE_STATE:
if (data->pm_state == DEVICE_PM_OFF_STATE) {
case PM_DEVICE_ACTIVE_STATE:
if (data->pm_state == PM_DEVICE_OFF_STATE) {
ret = fdc2x1x_set_shutdown(dev, false);
if (ret) {
return ret;
@ -508,11 +508,11 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
if (ret) {
return ret;
}
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
break;
case DEVICE_PM_LOW_POWER_STATE:
if (data->pm_state == DEVICE_PM_OFF_STATE) {
case PM_DEVICE_LOW_POWER_STATE:
if (data->pm_state == PM_DEVICE_OFF_STATE) {
ret = fdc2x1x_set_shutdown(dev, false);
if (ret) {
return ret;
@ -522,13 +522,13 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
if (ret) {
return ret;
}
data->pm_state = DEVICE_PM_LOW_POWER_STATE;
data->pm_state = PM_DEVICE_LOW_POWER_STATE;
break;
case DEVICE_PM_OFF_STATE:
case PM_DEVICE_OFF_STATE:
if (cfg->sd_gpio->name) {
ret = fdc2x1x_set_shutdown(dev, true);
data->pm_state = DEVICE_PM_OFF_STATE;
data->pm_state = PM_DEVICE_OFF_STATE;
} else {
LOG_ERR("SD pin not defined");
ret = -EINVAL;
@ -549,13 +549,13 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
uint32_t new_state;
int ret = 0;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
new_state = *(uint32_t *)context;
if (new_state != data->pm_state) {
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_OFF_STATE:
case PM_DEVICE_ACTIVE_STATE:
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_OFF_STATE:
ret = fdc2x1x_set_pm_state(dev, new_state);
break;
default:
@ -563,7 +563,7 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
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;
}
@ -655,7 +655,7 @@ static int fdc2x1x_sample_fetch(const struct device *dev,
#ifdef CONFIG_PM_DEVICE
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");
return -ENXIO;
}

View file

@ -25,7 +25,7 @@ static void fdc2x1x_thread_cb(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
/* 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;
}
#endif

View file

@ -470,7 +470,7 @@ static int lis2mdl_init(const struct device *dev)
}
#ifdef CONFIG_PM_DEVICE
lis2mdl->power_state = DEVICE_PM_ACTIVE_STATE;
lis2mdl->power_state = PM_DEVICE_ACTIVE_STATE;
#endif
#ifdef CONFIG_LIS2MDL_TRIGGER
@ -490,7 +490,7 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
{
int status = 0;
if (new_state == DEVICE_PM_ACTIVE_STATE) {
if (new_state == PM_DEVICE_ACTIVE_STATE) {
if (config->single_mode) {
status = lis2mdl_operating_mode_set(lis2mdl->ctx,
LIS2MDL_SINGLE_TRIGGER);
@ -501,12 +501,12 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
if (status) {
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");
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == PM_DEVICE_OFF_STATE);
status = lis2mdl_operating_mode_set(lis2mdl->ctx,
LIS2MDL_POWER_DOWN);
if (status) {
@ -529,14 +529,14 @@ static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
uint32_t new_state;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
case PM_DEVICE_SET_POWER_STATE:
new_state = *((const uint32_t *)context);
if (new_state != current_state) {
status = lis2mdl_set_power_state(lis2mdl, config,
new_state);
}
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = current_state;
break;
default:

View file

@ -209,7 +209,7 @@ static int qdec_nrfx_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
struct qdec_nrfx_data *data = &qdec_nrfx_data;
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
return 0;
@ -242,18 +242,18 @@ static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data,
return 0;
}
if (old_state == DEVICE_PM_ACTIVE_STATE) {
if (old_state == PM_DEVICE_ACTIVE_STATE) {
/* device must be suspended */
nrfx_qdec_disable();
qdec_nrfx_gpio_ctrl(false);
}
if (new_state == DEVICE_PM_OFF_STATE) {
if (new_state == PM_DEVICE_OFF_STATE) {
/* device must be uninitialized */
nrfx_qdec_uninit();
}
if (new_state == DEVICE_PM_ACTIVE_STATE) {
if (new_state == PM_DEVICE_ACTIVE_STATE) {
qdec_nrfx_gpio_ctrl(true);
nrfx_qdec_enable();
}
@ -276,11 +276,11 @@ static int qdec_nrfx_pm_control(const struct device *dev,
LOG_DBG("");
switch (ctrl_command) {
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
err = qdec_nrfx_pm_get_state(data, context);
break;
case DEVICE_PM_SET_POWER_STATE:
case PM_DEVICE_SET_POWER_STATE:
err = qdec_nrfx_pm_set_state(data, *((uint32_t *)context));
break;

View file

@ -224,7 +224,7 @@ static int vcnl4040_device_ctrl(const struct device *dev,
{
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;
uint16_t ps_conf;
@ -238,7 +238,7 @@ static int vcnl4040_device_ctrl(const struct device *dev,
if (ret < 0)
return ret;
#endif
if (device_pm_state == DEVICE_PM_ACTIVE_STATE) {
if (device_pm_state == PM_DEVICE_ACTIVE_STATE) {
/* Clear proximity shutdown */
ps_conf &= ~VCNL4040_PS_SD_MASK;
@ -274,8 +274,8 @@ static int vcnl4040_device_ctrl(const struct device *dev,
#endif
}
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) {
*((uint32_t *)context) = DEVICE_PM_ACTIVE_STATE;
} else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
*((uint32_t *)context) = PM_DEVICE_ACTIVE_STATE;
}
if (cb) {

View file

@ -402,7 +402,7 @@ static int uart_cc13xx_cc26xx_set_power_state(const struct device *dev,
{
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)) {
if (get_dev_conf(dev)->regs ==
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;
}
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_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);
/*
* 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;
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context);
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);
}
} 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;
}
@ -581,7 +581,7 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = {
#define UART_CC13XX_CC26XX_INIT_PM_STATE \
do { \
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE; \
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; \
} while (0)
#else
#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);
/* If next device power state is LOW or SUSPEND power state */
if (next_state == DEVICE_PM_LOW_POWER_STATE ||
next_state == DEVICE_PM_SUSPEND_STATE) {
if (next_state == PM_DEVICE_LOW_POWER_STATE ||
next_state == PM_DEVICE_SUSPEND_STATE) {
/*
* If uart device is busy with transmitting, the driver will
* 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;
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));
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
ret = uart_npcx_get_power_state(dev, (uint32_t *)context);
break;
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,
uint32_t new_state)
{
if (new_state == DEVICE_PM_ACTIVE_STATE) {
if (new_state == PM_DEVICE_ACTIVE_STATE) {
uart_nrfx_pins_enable(dev, true);
nrf_uart_enable(uart0_addr);
if (RX_PIN_USED) {
@ -1148,9 +1148,9 @@ static void uart_nrfx_set_power_state(const struct device *dev,
NRF_UART_TASK_STARTRX);
}
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == PM_DEVICE_OFF_STATE);
nrf_uart_disable(uart0_addr);
uart_nrfx_pins_enable(dev, false);
}
@ -1160,9 +1160,9 @@ static int uart_nrfx_pm_control(const struct device *dev,
uint32_t ctrl_command,
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);
if (new_state != current_state) {
@ -1170,7 +1170,7 @@ static int uart_nrfx_pm_control(const struct device *dev,
current_state = new_state;
}
} 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;
}

View file

@ -1376,7 +1376,7 @@ static void uarte_nrfx_poll_out(const struct device *dev, unsigned char c)
int key;
#ifdef CONFIG_PM_DEVICE
if (data->pm_state != DEVICE_PM_ACTIVE_STATE) {
if (data->pm_state != PM_DEVICE_ACTIVE_STATE) {
return;
}
#endif
@ -1669,7 +1669,7 @@ static int uarte_instance_init(const struct device *dev,
}
#ifdef CONFIG_PM_DEVICE
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
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);
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);
nrf_uarte_enable(uarte);
@ -1801,14 +1801,14 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
#endif
}
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_STATE ||
new_state == PM_DEVICE_OFF_STATE);
/* if pm is already not active, driver will stay indefinitely
* 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;
}
@ -1867,14 +1867,14 @@ static int uarte_nrfx_pm_control(const struct device *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);
if (new_state != data->pm_state) {
uarte_nrfx_set_power_state(dev, new_state);
}
} 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;
}

View file

@ -1410,7 +1410,7 @@ static int uart_stm32_init(const struct device *dev)
config->uconf.irq_config_func(dev);
#endif
#ifdef CONFIG_PM_DEVICE
data->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif /* CONFIG_PM_DEVICE */
#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);
/* setting a low power mode */
if (new_state != DEVICE_PM_ACTIVE_STATE) {
if (new_state != PM_DEVICE_ACTIVE_STATE) {
#ifdef USART_ISR_BUSY
/* Make sure that no USART transfer is on-going */
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);
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
uint32_t new_state = *((const uint32_t *)context);
if (new_state != data->pm_state) {
uart_stm32_set_power_state(dev, new_state);
}
} 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;
}

View file

@ -215,7 +215,7 @@ static int spi_cc13xx_cc26xx_set_power_state(const struct device *dev,
{
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)) {
if (get_dev_config(dev)->base ==
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;
} else {
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
new_state == DEVICE_PM_SUSPEND_STATE ||
new_state == DEVICE_PM_OFF_STATE);
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
new_state == PM_DEVICE_SUSPEND_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);
/*
* Release power dependency
@ -256,7 +256,7 @@ static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
{
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);
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);
}
} 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;
}
@ -338,7 +338,7 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
#ifdef CONFIG_PM_DEVICE
#define SPI_CC13XX_CC26XX_INIT_PM_STATE \
do { \
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE; \
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE; \
} while (0)
#else
#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
dev_data->pm_state = DEVICE_PM_ACTIVE_STATE;
dev_data->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
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);
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);
if (new_state != data->pm_state) {
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
ret = init_spi(dev);
/* Force reconfiguration before next transfer */
data->ctx.config = NULL;
break;
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE:
if (data->pm_state == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_SUSPEND_STATE:
case PM_DEVICE_OFF_STATE:
if (data->pm_state == PM_DEVICE_ACTIVE_STATE) {
nrfx_spi_uninit(&config->spi);
}
break;
@ -319,7 +319,7 @@ static int spi_nrfx_pm_control(const struct device *dev,
}
}
} 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;
}

View file

@ -324,8 +324,8 @@ static int init_spim(const struct device *dev)
}
#ifdef CONFIG_PM_DEVICE
data->pm_state = DEVICE_PM_ACTIVE_STATE;
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE;
data->pm_state = PM_DEVICE_ACTIVE_STATE;
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
#endif
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);
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);
if (new_state != data->pm_state) {
switch (new_state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
ret = init_spim(dev);
/* Force reconfiguration before next transfer */
data->ctx.config = NULL;
break;
case DEVICE_PM_LOW_POWER_STATE:
case DEVICE_PM_SUSPEND_STATE:
case DEVICE_PM_OFF_STATE:
if (data->pm_state == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_LOW_POWER_STATE:
case PM_DEVICE_SUSPEND_STATE:
case PM_DEVICE_OFF_STATE:
if (data->pm_state == PM_DEVICE_ACTIVE_STATE) {
nrfx_spim_uninit(&config->spim);
}
break;
@ -367,7 +367,7 @@ static int spim_nrfx_pm_control(const struct device *dev,
}
}
} 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;
}

View file

@ -663,7 +663,7 @@ static inline int device_set_power_state(const struct device *dev,
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);
}
@ -687,7 +687,7 @@ static inline int device_get_power_state(const struct device *dev,
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);
}

View file

@ -24,24 +24,24 @@ extern "C" {
struct device;
/** @def DEVICE_PM_ACTIVE_STATE
/** @def PM_DEVICE_ACTIVE_STATE
*
* @brief device is in ACTIVE power state
*
* @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
*
* @details Device context is preserved by the HW and need not be
* 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
*
@ -49,9 +49,9 @@ struct device;
* Device drivers must save and restore or reinitialize any context
* 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
*
@ -61,9 +61,9 @@ struct device;
* Most device context is lost by the hardware. Device drivers must
* 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
*
@ -71,11 +71,11 @@ struct device;
* The device context is lost when this state is entered, so the OS
* 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 */
#define DEVICE_PM_SET_POWER_STATE 1
#define DEVICE_PM_GET_POWER_STATE 2
#define PM_DEVICE_SET_POWER_STATE 1
#define PM_DEVICE_GET_POWER_STATE 2
typedef void (*device_pm_cb)(const struct device *dev,
int status, void *context, void *arg);
@ -108,7 +108,7 @@ struct device_pm {
/** Bit position in device_pm::atomic_flags that records whether the
* 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

View file

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

View file

@ -66,17 +66,17 @@ void main(void)
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
rc = 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);
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);
k_sleep(K_SECONDS(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));
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");

View file

@ -151,7 +151,7 @@ void main(void)
#if IS_ENABLED(CONFIG_PM_DEVICE)
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);
if (err != 0) {
printk("FAILED\n");

View file

@ -79,11 +79,11 @@ void main(void)
#ifdef CONFIG_PM_DEVICE
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);
printk("set low power state for 2s\n");
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);
#endif
}

View file

@ -43,13 +43,13 @@ static void pm_cb(const struct device *dev,
ARG_UNUSED(arg);
switch (*(uint32_t *)context) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
printk("Enter ACTIVE_STATE ");
break;
case DEVICE_PM_LOW_POWER_STATE:
case PM_DEVICE_LOW_POWER_STATE:
printk("Enter LOW_POWER_STATE ");
break;
case DEVICE_PM_OFF_STATE:
case PM_DEVICE_OFF_STATE:
printk("Enter OFF_STATE ");
break;
}
@ -97,13 +97,13 @@ void main(void)
/* Testing the power modes */
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);
p_state = DEVICE_PM_OFF_STATE;
p_state = PM_DEVICE_OFF_STATE;
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);
#endif
@ -132,10 +132,10 @@ void main(void)
#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);
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);
#elif CONFIG_FDC2X1X_TRIGGER_NONE
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;
k_poll_signal_reset(&dev->pm->signal);
if (result == DEVICE_PM_ACTIVE_STATE) {
if (result == PM_DEVICE_ACTIVE_STATE) {
printk("Dummy device resumed\n");
ret = 0;
} else {
@ -101,7 +101,7 @@ static uint32_t dummy_get_power_state(const struct device *dev)
static int dummy_suspend(const struct device *dev)
{
printk("child suspending..\n");
device_power_state = DEVICE_PM_SUSPEND_STATE;
device_power_state = PM_DEVICE_SUSPEND_STATE;
return 0;
}
@ -109,7 +109,7 @@ static int dummy_suspend(const struct device *dev)
static int dummy_resume_from_suspend(const struct device *dev)
{
printk("child resuming..\n");
device_power_state = DEVICE_PM_ACTIVE_STATE;
device_power_state = PM_DEVICE_ACTIVE_STATE;
return 0;
}
@ -121,14 +121,14 @@ static int dummy_device_pm_ctrl(const struct device *dev,
int ret = 0;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = dummy_resume_from_suspend(dev);
} else {
ret = dummy_suspend(dev);
}
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = dummy_get_power_state(dev);
break;
default:
@ -156,7 +156,7 @@ int dummy_init(const struct device *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_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)
{
printk("parent suspending..\n");
parent_power_state = DEVICE_PM_SUSPEND_STATE;
parent_power_state = PM_DEVICE_SUSPEND_STATE;
return 0;
}
@ -40,7 +40,7 @@ static int dummy_suspend(const struct device *dev)
static int dummy_resume_from_suspend(const struct device *dev)
{
printk("parent resuming..\n");
parent_power_state = DEVICE_PM_ACTIVE_STATE;
parent_power_state = PM_DEVICE_ACTIVE_STATE;
return 0;
}
@ -52,14 +52,14 @@ static int dummy_parent_pm_ctrl(const struct device *dev,
int ret = 0;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = dummy_resume_from_suspend(dev);
} else {
ret = dummy_suspend(dev);
}
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = dummy_get_power_state(dev);
break;
default:
@ -78,7 +78,7 @@ static const struct dummy_parent_api funcs = {
int dummy_parent_init(const struct device *dev)
{
pm_device_enable(dev);
parent_power_state = DEVICE_PM_ACTIVE_STATE;
parent_power_state = PM_DEVICE_ACTIVE_STATE;
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);
ret = device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE,
ret = device_set_power_state(dev, PM_DEVICE_SUSPEND_STATE,
NULL, NULL);
if (ret != 0) {
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);
ret = device_set_power_state(dev, DEVICE_PM_ACTIVE_STATE,
ret = device_set_power_state(dev, PM_DEVICE_ACTIVE_STATE,
NULL, NULL);
if (ret != 0) {
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)
{
return _pm_devices(DEVICE_PM_SUSPEND_STATE);
return _pm_devices(PM_DEVICE_SUSPEND_STATE);
}
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)
{
return _pm_devices(DEVICE_PM_FORCE_SUSPEND_STATE);
return _pm_devices(PM_DEVICE_FORCE_SUSPEND_STATE);
}
void pm_resume_devices(void)
@ -109,7 +109,7 @@ void pm_resume_devices(void)
device_idx_t idx = pm_devices[pmi];
device_set_power_state(&all_devices[idx],
DEVICE_PM_ACTIVE_STATE,
PM_DEVICE_ACTIVE_STATE,
NULL, NULL);
++pmi;
}
@ -168,15 +168,15 @@ void pm_create_device_list(void)
const char *device_pm_state_str(uint32_t state)
{
switch (state) {
case DEVICE_PM_ACTIVE_STATE:
case PM_DEVICE_ACTIVE_STATE:
return "active";
case DEVICE_PM_LOW_POWER_STATE:
case PM_DEVICE_LOW_POWER_STATE:
return "low power";
case DEVICE_PM_SUSPEND_STATE:
case PM_DEVICE_SUSPEND_STATE:
return "suspend";
case DEVICE_PM_FORCE_SUSPEND_STATE:
case PM_DEVICE_FORCE_SUSPEND_STATE:
return "force suspend";
case DEVICE_PM_OFF_STATE:
case PM_DEVICE_OFF_STATE:
return "off";
default:
return "";

View file

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

View file

@ -146,7 +146,7 @@ static int cmd_device_list(const struct shell *shell,
state = "DISABLED";
} else {
#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);
if (!err) {

View file

@ -316,8 +316,8 @@ void test_dummy_device_pm(void)
test_build_suspend_device_list();
/* Set device state to DEVICE_PM_ACTIVE_STATE */
ret = device_set_power_state(dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
/* Set device state to PM_DEVICE_ACTIVE_STATE */
ret = device_set_power_state(dev, PM_DEVICE_ACTIVE_STATE, NULL, NULL);
if (ret == -ENOSYS) {
TC_PRINT("Power management not supported on device");
ztest_test_skip();
@ -330,19 +330,19 @@ void test_dummy_device_pm(void)
ret = device_get_power_state(dev, &device_power_state);
zassert_true((ret == 0),
"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");
/* Set device state to DEVICE_PM_FORCE_SUSPEND_STATE */
/* Set device state to PM_DEVICE_FORCE_SUSPEND_STATE */
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");
ret = device_get_power_state(dev, &device_power_state);
zassert_true((ret == 0),
"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");
}
#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;
int ret = 0;
if (command == DEVICE_PM_SET_POWER_STATE) {
if (*(uint32_t *)context == DEVICE_PM_SUSPEND_STATE) {
if (command == PM_DEVICE_SET_POWER_STATE) {
if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
ret = net_if_suspend(ctx->iface);
if (ret == -EBUSY) {
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);
}
} else {
@ -149,14 +149,14 @@ void test_pm(void)
*/
k_yield();
ret = device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE,
ret = device_set_power_state(dev, PM_DEVICE_SUSPEND_STATE,
NULL, NULL);
zassert_true(ret == 0, "Could not set state");
zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
/* 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);
zassert_true(ret == -EALREADY, "Could change state");
@ -167,13 +167,13 @@ void test_pm(void)
(struct sockaddr *)&addr4, sizeof(struct sockaddr_in));
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);
zassert_true(ret == 0, "Could not set state");
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);
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)
{
device_power_state = DEVICE_PM_SUSPEND_STATE;
device_power_state = PM_DEVICE_SUSPEND_STATE;
return 0;
}
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;
}
@ -45,14 +45,14 @@ static int dummy_device_pm_ctrl(const struct device *dev,
int ret = 0;
switch (ctrl_command) {
case DEVICE_PM_SET_POWER_STATE:
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
case PM_DEVICE_SET_POWER_STATE:
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
ret = dummy_resume_from_suspend(dev);
} else {
ret = dummy_suspend(dev);
}
break;
case DEVICE_PM_GET_POWER_STATE:
case PM_DEVICE_GET_POWER_STATE:
*((uint32_t *)context) = dummy_get_power_state(dev);
break;
default:

View file

@ -42,7 +42,7 @@ __weak void pm_power_state_set(struct pm_state_info info)
uint32_t device_power_state;
/* at this point, devices have been deactivated */
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
* 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 */
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;
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*/
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;
}
@ -180,11 +180,11 @@ void test_power_state_notification(void)
uint32_t 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);
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 */
api->open(dev);
}