pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control callback signature. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
217e610d8f
commit
26ad8376bd
50 changed files with 96 additions and 163 deletions
|
@ -520,8 +520,7 @@ static int st7735r_enter_sleep(struct st7735r_data *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct st7735r_data *data = (struct st7735r_data *)dev->data;
|
struct st7735r_data *data = (struct st7735r_data *)dev->data;
|
||||||
|
|
|
@ -409,7 +409,7 @@ static void st7789v_enter_sleep(struct st7789v_data *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
||||||
|
|
|
@ -294,8 +294,7 @@ static int entropy_cc13xx_cc26xx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
|
static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
|
@ -186,8 +186,7 @@ void eth_mcux_phy_stop(struct eth_context *context);
|
||||||
|
|
||||||
static int eth_mcux_device_pm_control(const struct device *dev,
|
static int eth_mcux_device_pm_control(const struct device *dev,
|
||||||
uint32_t command,
|
uint32_t command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
struct eth_context *eth_ctx = (struct eth_context *)dev->data;
|
struct eth_context *eth_ctx = (struct eth_context *)dev->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
@ -629,8 +629,7 @@ static int spi_flash_at45_init(const struct device *dev)
|
||||||
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
||||||
static int spi_flash_at45_pm_control(const struct device *dev,
|
static int spi_flash_at45_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
struct spi_flash_at45_data *dev_data = get_dev_data(dev);
|
struct spi_flash_at45_data *dev_data = get_dev_data(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);
|
||||||
|
|
|
@ -461,7 +461,7 @@ static inline int gpio_dw_resume_from_suspend_port(const struct device *port)
|
||||||
*/
|
*/
|
||||||
static int gpio_dw_device_ctrl(const struct device *port,
|
static int gpio_dw_device_ctrl(const struct device *port,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -605,7 +605,7 @@ static int gpio_stm32_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int gpio_stm32_pm_device_ctrl(const struct device *dev,
|
static int gpio_stm32_pm_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
struct gpio_stm32_data *data = dev->data;
|
struct gpio_stm32_data *data = dev->data;
|
||||||
uint32_t new_state;
|
uint32_t new_state;
|
||||||
|
|
|
@ -369,8 +369,7 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
|
static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ static int init_twi(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static int twi_nrfx_pm_control(const struct device *dev,
|
static int twi_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
enum pm_device_state pm_current_state = get_dev_data(dev)->pm_state;
|
enum pm_device_state pm_current_state = get_dev_data(dev)->pm_state;
|
||||||
|
|
|
@ -263,7 +263,7 @@ static int init_twim(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static int twim_nrfx_pm_control(const struct device *dev,
|
static int twim_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
enum pm_device_state pm_current_state = get_dev_data(dev)->pm_state;
|
enum pm_device_state pm_current_state = get_dev_data(dev)->pm_state;
|
||||||
|
|
|
@ -194,8 +194,7 @@ static enum pm_device_state arc_v2_irq_unit_get_state(const struct device *dev)
|
||||||
*/
|
*/
|
||||||
static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
|
static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned int key = arch_irq_lock();
|
unsigned int key = arch_irq_lock();
|
||||||
|
|
|
@ -315,8 +315,7 @@ int ioapic_resume_from_suspend(const struct device *port)
|
||||||
__pinned_func
|
__pinned_func
|
||||||
static int ioapic_device_ctrl(const struct device *dev,
|
static int ioapic_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -414,8 +414,7 @@ int loapic_resume(const struct device *port)
|
||||||
__pinned_func
|
__pinned_func
|
||||||
static int loapic_device_ctrl(const struct device *port,
|
static int loapic_device_ctrl(const struct device *port,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ static int led_pwm_pm_set_state(const struct device *dev,
|
||||||
const struct led_pwm *led_pwm = &config->led[i];
|
const struct led_pwm *led_pwm = &config->led[i];
|
||||||
|
|
||||||
LOG_DBG("Switching PWM %p to state %" PRIu32, led_pwm->dev, new_state);
|
LOG_DBG("Switching PWM %p to state %" PRIu32, led_pwm->dev, new_state);
|
||||||
int err = pm_device_state_set(led_pwm->dev, new_state, NULL, NULL);
|
int err = pm_device_state_set(led_pwm->dev, new_state);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
LOG_ERR("Cannot switch PWM %p power state", led_pwm->dev);
|
LOG_ERR("Cannot switch PWM %p power state", led_pwm->dev);
|
||||||
|
@ -178,7 +178,7 @@ static int led_pwm_pm_set_state(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int led_pwm_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int led_pwm_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
|
@ -3505,7 +3505,7 @@ static void shutdown_uart(void)
|
||||||
HL7800_IO_DBG_LOG("Power OFF the UART");
|
HL7800_IO_DBG_LOG("Power OFF the UART");
|
||||||
uart_irq_rx_disable(ictx.mdm_ctx.uart_dev);
|
uart_irq_rx_disable(ictx.mdm_ctx.uart_dev);
|
||||||
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
|
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
|
||||||
PM_DEVICE_STATE_OFF, NULL, NULL);
|
PM_DEVICE_STATE_OFF);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
LOG_ERR("Error disabling UART peripheral (%d)", rc);
|
LOG_ERR("Error disabling UART peripheral (%d)", rc);
|
||||||
}
|
}
|
||||||
|
@ -3522,7 +3522,7 @@ static void power_on_uart(void)
|
||||||
if (!ictx.uart_on) {
|
if (!ictx.uart_on) {
|
||||||
HL7800_IO_DBG_LOG("Power ON the UART");
|
HL7800_IO_DBG_LOG("Power ON the UART");
|
||||||
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
|
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
|
||||||
PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
PM_DEVICE_STATE_ACTIVE);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
LOG_ERR("Error enabling UART peripheral (%d)", rc);
|
LOG_ERR("Error enabling UART peripheral (%d)", rc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ int mdm_receiver_sleep(struct mdm_receiver_context *ctx)
|
||||||
{
|
{
|
||||||
uart_irq_rx_disable(ctx->uart_dev);
|
uart_irq_rx_disable(ctx->uart_dev);
|
||||||
#ifdef PM_DEVICE_STATE_LOW_POWER
|
#ifdef PM_DEVICE_STATE_LOW_POWER
|
||||||
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_LOW_POWER, NULL, NULL);
|
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_LOW_POWER);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ int mdm_receiver_sleep(struct mdm_receiver_context *ctx)
|
||||||
int mdm_receiver_wake(struct mdm_receiver_context *ctx)
|
int mdm_receiver_wake(struct mdm_receiver_context *ctx)
|
||||||
{
|
{
|
||||||
#ifdef PM_DEVICE_STATE_LOW_POWER
|
#ifdef PM_DEVICE_STATE_LOW_POWER
|
||||||
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
pm_device_state_set(ctx->uart_dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
#endif
|
#endif
|
||||||
uart_irq_rx_enable(ctx->uart_dev);
|
uart_irq_rx_enable(ctx->uart_dev);
|
||||||
|
|
||||||
|
|
|
@ -346,9 +346,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
|
||||||
#define PWM_NRFX_PM_CONTROL(idx) \
|
#define PWM_NRFX_PM_CONTROL(idx) \
|
||||||
static int pwm_##idx##_nrfx_pm_control(const struct device *dev, \
|
static int pwm_##idx##_nrfx_pm_control(const struct device *dev, \
|
||||||
uint32_t ctrl_command, \
|
uint32_t ctrl_command, \
|
||||||
enum pm_device_state *state, \
|
enum pm_device_state *state) \
|
||||||
pm_device_cb cb, \
|
|
||||||
void *arg) \
|
|
||||||
{ \
|
{ \
|
||||||
static enum pm_device_state current_state = PM_DEVICE_STATE_ACTIVE; \
|
static enum pm_device_state current_state = PM_DEVICE_STATE_ACTIVE; \
|
||||||
int ret = 0; \
|
int ret = 0; \
|
||||||
|
|
|
@ -410,8 +410,7 @@ static int apds9960_init_interrupt(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static int apds9960_device_ctrl(const struct device *dev,
|
static int apds9960_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
const struct apds9960_config *config = dev->config;
|
const struct apds9960_config *config = dev->config;
|
||||||
struct apds9960_data *data = dev->data;
|
struct apds9960_data *data = dev->data;
|
||||||
|
|
|
@ -391,7 +391,7 @@ static int bme280_chip_init(const struct device *dev)
|
||||||
|
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
|
int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
struct bme280_data *data = to_data(dev);
|
struct bme280_data *data = to_data(dev);
|
||||||
|
|
||||||
|
|
|
@ -589,8 +589,7 @@ static uint32_t bmp388_get_power_state(const struct device *dev)
|
||||||
static int bmp388_device_ctrl(
|
static int bmp388_device_ctrl(
|
||||||
const struct device *dev,
|
const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -543,8 +543,7 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
|
||||||
|
|
||||||
static int fdc2x1x_device_pm_ctrl(const struct device *dev,
|
static int fdc2x1x_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
struct fdc2x1x_data *data = dev->data;
|
struct fdc2x1x_data *data = dev->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
@ -483,7 +483,7 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
struct lis2mdl_data *lis2mdl = dev->data;
|
struct lis2mdl_data *lis2mdl = dev->data;
|
||||||
const struct lis2mdl_config *const config = dev->config;
|
const struct lis2mdl_config *const config = dev->config;
|
||||||
|
|
|
@ -268,7 +268,7 @@ static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data,
|
||||||
|
|
||||||
static int qdec_nrfx_pm_control(const struct device *dev,
|
static int qdec_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
struct qdec_nrfx_data *data = &qdec_nrfx_data;
|
struct qdec_nrfx_data *data = &qdec_nrfx_data;
|
||||||
int err;
|
int err;
|
||||||
|
|
|
@ -220,8 +220,7 @@ static int vcnl4040_ambient_setup(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static int vcnl4040_device_ctrl(const struct device *dev,
|
static int vcnl4040_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state,
|
enum pm_device_state *state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -447,8 +447,7 @@ static int uart_cc13xx_cc26xx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int uart_cc13xx_cc26xx_pm_control(const struct device *dev,
|
static int uart_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,7 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
/* Implements the device power management control functionality */
|
/* Implements the device power management control functionality */
|
||||||
static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -1160,7 +1160,7 @@ static void uart_nrfx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int uart_nrfx_pm_control(const struct device *dev,
|
static int uart_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
static enum pm_device_state current_state = PM_DEVICE_STATE_ACTIVE;
|
static enum pm_device_state current_state = PM_DEVICE_STATE_ACTIVE;
|
||||||
|
|
||||||
|
|
|
@ -1918,7 +1918,7 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int uarte_nrfx_pm_control(const struct device *dev,
|
static int uarte_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
struct uarte_nrfx_data *data = get_dev_data(dev);
|
struct uarte_nrfx_data *data = get_dev_data(dev);
|
||||||
|
|
||||||
|
|
|
@ -1465,8 +1465,7 @@ static int uart_stm32_set_power_state(const struct device *dev,
|
||||||
*/
|
*/
|
||||||
static int uart_stm32_pm_control(const struct device *dev,
|
static int uart_stm32_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
struct uart_stm32_data *data = DEV_DATA(dev);
|
struct uart_stm32_data *data = DEV_DATA(dev);
|
||||||
|
|
||||||
|
|
|
@ -252,8 +252,7 @@ static int spi_cc13xx_cc26xx_set_power_state(const struct device *dev,
|
||||||
|
|
||||||
static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
|
static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -286,7 +286,7 @@ static int init_spi(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static int spi_nrfx_pm_control(const struct device *dev,
|
static int spi_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct spi_nrfx_data *data = get_dev_data(dev);
|
struct spi_nrfx_data *data = get_dev_data(dev);
|
||||||
|
|
|
@ -334,7 +334,7 @@ static int init_spim(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static int spim_nrfx_pm_control(const struct device *dev,
|
static int spim_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct spi_nrfx_data *data = get_dev_data(dev);
|
struct spi_nrfx_data *data = get_dev_data(dev);
|
||||||
|
|
|
@ -32,8 +32,7 @@ int __weak sys_clock_driver_init(const struct device *dev)
|
||||||
|
|
||||||
int __weak sys_clock_device_ctrl(const struct device *dev,
|
int __weak sys_clock_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,8 +362,7 @@ struct device {
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
/** Power Management function */
|
/** Power Management function */
|
||||||
int (*pm_control)(const struct device *dev, uint32_t command,
|
int (*pm_control)(const struct device *dev, uint32_t command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state);
|
||||||
void *arg);
|
|
||||||
/** Pointer to device instance power management data */
|
/** Pointer to device instance power management data */
|
||||||
struct pm_device * const pm;
|
struct pm_device * const pm;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,10 +46,8 @@ extern int sys_clock_driver_init(const struct device *dev);
|
||||||
* management. It is a weak symbol that will be implemented as a noop
|
* management. It is a weak symbol that will be implemented as a noop
|
||||||
* if undefined in the clock driver.
|
* if undefined in the clock driver.
|
||||||
*/
|
*/
|
||||||
extern int clock_device_ctrl(const struct device *dev,
|
extern int clock_device_ctrl(const struct device *dev, uint32_t ctrl_command,
|
||||||
uint32_t ctrl_command,
|
enum pm_device_state *state);
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
|
||||||
void *arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set system clock timeout
|
* @brief Set system clock timeout
|
||||||
|
|
|
@ -67,10 +67,6 @@ enum pm_device_state {
|
||||||
/** Device PM get state control command. */
|
/** Device PM get state control command. */
|
||||||
#define PM_DEVICE_STATE_GET 1
|
#define PM_DEVICE_STATE_GET 1
|
||||||
|
|
||||||
typedef void (*pm_device_cb)(const struct device *dev,
|
|
||||||
int status, enum pm_device_state *state,
|
|
||||||
void *arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Device PM info
|
* @brief Device PM info
|
||||||
*/
|
*/
|
||||||
|
@ -114,15 +110,12 @@ const char *pm_device_state_str(enum pm_device_state state);
|
||||||
* Note that devices may support just some of the device power states
|
* Note that devices may support just some of the device power states
|
||||||
* @param dev Pointer to device structure of the driver instance.
|
* @param dev Pointer to device structure of the driver instance.
|
||||||
* @param device_power_state Device power state to be set
|
* @param device_power_state Device power state to be set
|
||||||
* @param cb Callback function to notify device power status
|
|
||||||
* @param arg Caller passed argument to callback function
|
|
||||||
*
|
*
|
||||||
* @retval 0 If successful in queuing the request or changing the state.
|
* @retval 0 If successful in queuing the request or changing the state.
|
||||||
* @retval Errno Negative errno code if failure. Callback will not be called.
|
* @retval Errno Negative errno code if failure.
|
||||||
*/
|
*/
|
||||||
int pm_device_state_set(const struct device *dev,
|
int pm_device_state_set(const struct device *dev,
|
||||||
enum pm_device_state device_power_state,
|
enum pm_device_state device_power_state);
|
||||||
pm_device_cb cb, void *arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Call the get power state function of a device
|
* @brief Call the get power state function of a device
|
||||||
|
|
|
@ -66,17 +66,17 @@ void main(void)
|
||||||
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
|
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
|
||||||
|
|
||||||
printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
|
printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
|
||||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER, NULL, NULL);
|
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER);
|
||||||
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
|
k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
|
||||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE);
|
||||||
|
|
||||||
printk("Sleep %u s\n", SLEEP_S);
|
printk("Sleep %u s\n", SLEEP_S);
|
||||||
k_sleep(K_SECONDS(SLEEP_S));
|
k_sleep(K_SECONDS(SLEEP_S));
|
||||||
|
|
||||||
printk("Sleep %u s with UART off\n", SLEEP_S);
|
printk("Sleep %u s with UART off\n", SLEEP_S);
|
||||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER, NULL, NULL);
|
rc = pm_device_state_set(cons, PM_DEVICE_STATE_LOW_POWER);
|
||||||
k_sleep(K_SECONDS(SLEEP_S));
|
k_sleep(K_SECONDS(SLEEP_S));
|
||||||
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
rc = pm_device_state_set(cons, PM_DEVICE_STATE_ACTIVE);
|
||||||
|
|
||||||
printk("Entering system off; press BUTTON1 to restart\n");
|
printk("Entering system off; press BUTTON1 to restart\n");
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,7 @@ void main(void)
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
||||||
printk("Putting the flash device into low power state... ");
|
printk("Putting the flash device into low power state... ");
|
||||||
err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_LOW_POWER,
|
err = pm_device_state_set(flash_dev, PM_DEVICE_STATE_LOW_POWER);
|
||||||
NULL, NULL);
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printk("FAILED\n");
|
printk("FAILED\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -80,11 +80,11 @@ void main(void)
|
||||||
enum pm_device_state p_state;
|
enum pm_device_state p_state;
|
||||||
|
|
||||||
p_state = PM_DEVICE_STATE_LOW_POWER;
|
p_state = PM_DEVICE_STATE_LOW_POWER;
|
||||||
pm_device_state_set(dev, p_state, NULL, NULL);
|
pm_device_state_set(dev, p_state);
|
||||||
printk("set low power state for 2s\n");
|
printk("set low power state for 2s\n");
|
||||||
k_sleep(K_MSEC(2000));
|
k_sleep(K_MSEC(2000));
|
||||||
p_state = PM_DEVICE_STATE_ACTIVE;
|
p_state = PM_DEVICE_STATE_ACTIVE;
|
||||||
pm_device_state_set(dev, p_state, NULL, NULL);
|
pm_device_state_set(dev, p_state);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,12 @@ static void trigger_handler(const struct device *dev,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
static void pm_cb(const struct device *dev,
|
static void pm_info(enum pm_device_state state, int status)
|
||||||
int status,
|
|
||||||
uint32_t *state,
|
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
|
|
||||||
switch (*state) {
|
switch (state) {
|
||||||
case PM_DEVICE_STATE_ACTIVE:
|
case PM_DEVICE_STATE_ACTIVE:
|
||||||
printk("Enter ACTIVE_STATE ");
|
printk("Enter ACTIVE_STATE ");
|
||||||
break;
|
break;
|
||||||
|
@ -96,15 +93,19 @@ void main(void)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
/* Testing the power modes */
|
/* Testing the power modes */
|
||||||
enum pm_device_state p_state;
|
enum pm_device_state p_state;
|
||||||
|
int ret;
|
||||||
|
|
||||||
p_state = PM_DEVICE_STATE_LOW_POWER;
|
p_state = PM_DEVICE_STATE_LOW_POWER;
|
||||||
pm_device_state_set(dev, p_state, pm_cb, NULL);
|
ret = pm_device_state_set(dev, p_state);
|
||||||
|
pm_info(p_state, ret);
|
||||||
|
|
||||||
p_state = PM_DEVICE_STATE_OFF;
|
p_state = PM_DEVICE_STATE_OFF;
|
||||||
pm_device_state_set(dev, p_state, pm_cb, NULL);
|
ret = pm_device_state_set(dev, p_state);
|
||||||
|
pm_info(p_state, ret);
|
||||||
|
|
||||||
p_state = PM_DEVICE_STATE_ACTIVE;
|
p_state = PM_DEVICE_STATE_ACTIVE;
|
||||||
pm_device_state_set(dev, p_state, pm_cb, NULL);
|
ret = pm_device_state_set(dev, p_state);
|
||||||
|
pm_info(p_state, ret);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -133,10 +134,12 @@ void main(void)
|
||||||
|
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
p_state = PM_DEVICE_STATE_OFF;
|
p_state = PM_DEVICE_STATE_OFF;
|
||||||
pm_device_state_set(dev, p_state, pm_cb, NULL);
|
ret = pm_device_state_set(dev, p_state);
|
||||||
|
pm_info(p_state, ret);
|
||||||
k_sleep(K_MSEC(2000));
|
k_sleep(K_MSEC(2000));
|
||||||
p_state = PM_DEVICE_STATE_ACTIVE;
|
p_state = PM_DEVICE_STATE_ACTIVE;
|
||||||
pm_device_state_set(dev, p_state, pm_cb, NULL);
|
ret = pm_device_state_set(dev, p_state);
|
||||||
|
pm_info(p_state, ret);
|
||||||
#elif CONFIG_FDC2X1X_TRIGGER_NONE
|
#elif CONFIG_FDC2X1X_TRIGGER_NONE
|
||||||
k_sleep(K_MSEC(100));
|
k_sleep(K_MSEC(100));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -108,8 +108,7 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_device_pm_ctrl(const struct device *dev,
|
static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_parent_pm_ctrl(const struct device *dev,
|
static int dummy_parent_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -5532,8 +5532,7 @@ static int cmd_net_suspend(const struct shell *shell, size_t argc,
|
||||||
|
|
||||||
dev = net_if_get_device(iface);
|
dev = net_if_get_device(iface);
|
||||||
|
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND,
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND);
|
||||||
NULL, NULL);
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PR_INFO("Iface could not be suspended: ");
|
PR_INFO("Iface could not be suspended: ");
|
||||||
|
|
||||||
|
@ -5577,8 +5576,7 @@ static int cmd_net_resume(const struct shell *shell, size_t argc,
|
||||||
|
|
||||||
dev = net_if_get_device(iface);
|
dev = net_if_get_device(iface);
|
||||||
|
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE,
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
NULL, NULL);
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PR_INFO("Iface could not be resumed\n");
|
PR_INFO("Iface could not be resumed\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ static int _pm_devices(uint32_t state)
|
||||||
* Don't bother the device if it is currently
|
* Don't bother the device if it is currently
|
||||||
* in the right state.
|
* in the right state.
|
||||||
*/
|
*/
|
||||||
rc = pm_device_state_set(dev, state, NULL, NULL);
|
rc = pm_device_state_set(dev, state);
|
||||||
if ((rc != -ENOSYS) && (rc != 0)) {
|
if ((rc != -ENOSYS) && (rc != 0)) {
|
||||||
LOG_DBG("%s did not enter %s state: %d",
|
LOG_DBG("%s did not enter %s state: %d",
|
||||||
dev->name, pm_device_state_str(state),
|
dev->name, pm_device_state_str(state),
|
||||||
|
@ -103,8 +103,7 @@ void pm_resume_devices(void)
|
||||||
|
|
||||||
for (i = 0; i < num_susp; i++) {
|
for (i = 0; i < num_susp; i++) {
|
||||||
pm_device_state_set(__pm_device_slots_start[i],
|
pm_device_state_set(__pm_device_slots_start[i],
|
||||||
PM_DEVICE_STATE_ACTIVE,
|
PM_DEVICE_STATE_ACTIVE);
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
num_susp = 0;
|
num_susp = 0;
|
||||||
|
@ -130,15 +129,14 @@ const char *pm_device_state_str(enum pm_device_state state)
|
||||||
}
|
}
|
||||||
|
|
||||||
int pm_device_state_set(const struct device *dev,
|
int pm_device_state_set(const struct device *dev,
|
||||||
enum pm_device_state device_power_state,
|
enum pm_device_state device_power_state)
|
||||||
pm_device_cb cb, void *arg)
|
|
||||||
{
|
{
|
||||||
if (dev->pm_control == NULL) {
|
if (dev->pm_control == NULL) {
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev->pm_control(dev, PM_DEVICE_STATE_SET,
|
return dev->pm_control(dev, PM_DEVICE_STATE_SET,
|
||||||
&device_power_state, cb, arg);
|
&device_power_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pm_device_state_get(const struct device *dev,
|
int pm_device_state_get(const struct device *dev,
|
||||||
|
@ -149,5 +147,5 @@ int pm_device_state_get(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev->pm_control(dev, PM_DEVICE_STATE_GET,
|
return dev->pm_control(dev, PM_DEVICE_STATE_GET,
|
||||||
device_power_state, NULL, NULL);
|
device_power_state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ static void pm_device_runtime_state_set(struct pm_device *pm)
|
||||||
case PM_DEVICE_STATE_ACTIVE:
|
case PM_DEVICE_STATE_ACTIVE:
|
||||||
if ((dev->pm->usage == 0) && dev->pm->enable) {
|
if ((dev->pm->usage == 0) && dev->pm->enable) {
|
||||||
dev->pm->state = PM_DEVICE_STATE_SUSPENDING;
|
dev->pm->state = PM_DEVICE_STATE_SUSPENDING;
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND,
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND);
|
||||||
NULL, NULL);
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
dev->pm->state = PM_DEVICE_STATE_SUSPEND;
|
dev->pm->state = PM_DEVICE_STATE_SUSPEND;
|
||||||
}
|
}
|
||||||
|
@ -38,8 +37,7 @@ static void pm_device_runtime_state_set(struct pm_device *pm)
|
||||||
case PM_DEVICE_STATE_SUSPEND:
|
case PM_DEVICE_STATE_SUSPEND:
|
||||||
if ((dev->pm->usage > 0) || !dev->pm->enable) {
|
if ((dev->pm->usage > 0) || !dev->pm->enable) {
|
||||||
dev->pm->state = PM_DEVICE_STATE_RESUMING;
|
dev->pm->state = PM_DEVICE_STATE_RESUMING;
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE,
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
NULL, NULL);
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
dev->pm->state = PM_DEVICE_STATE_ACTIVE;
|
dev->pm->state = PM_DEVICE_STATE_ACTIVE;
|
||||||
}
|
}
|
||||||
|
@ -102,13 +100,9 @@ static int pm_device_request(const struct device *dev,
|
||||||
* the gpio. Lets just power on/off the device.
|
* the gpio. Lets just power on/off the device.
|
||||||
*/
|
*/
|
||||||
if (dev->pm->usage == 1) {
|
if (dev->pm->usage == 1) {
|
||||||
(void)pm_device_state_set(dev,
|
(void)pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
PM_DEVICE_STATE_ACTIVE,
|
|
||||||
NULL, NULL);
|
|
||||||
} else if (dev->pm->usage == 0) {
|
} else if (dev->pm->usage == 0) {
|
||||||
(void)pm_device_state_set(dev,
|
(void)pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND);
|
||||||
PM_DEVICE_STATE_SUSPEND,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
#define UART_DEVICE_NAME DT_LABEL(DT_NODELABEL(LABEL))
|
#define UART_DEVICE_NAME DT_LABEL(DT_NODELABEL(LABEL))
|
||||||
#define HAS_RX DT_NODE_HAS_PROP(DT_NODELABEL(LABEL), rx_pin)
|
#define HAS_RX DT_NODE_HAS_PROP(DT_NODELABEL(LABEL), rx_pin)
|
||||||
|
|
||||||
static const struct device *exp_dev;
|
|
||||||
static enum pm_device_state exp_state;
|
|
||||||
static void *exp_arg;
|
|
||||||
static volatile int callback_cnt;
|
|
||||||
|
|
||||||
static void polling_verify(const struct device *dev, bool is_async, bool active)
|
static void polling_verify(const struct device *dev, bool is_async, bool active)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
@ -126,18 +121,8 @@ static void communication_verify(const struct device *dev, bool active)
|
||||||
zassert_equal(power_state, exp_state, NULL); \
|
zassert_equal(power_state, exp_state, NULL); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static void pm_callback(const struct device *dev,
|
|
||||||
int status, enum pm_device_state *state, void *arg)
|
|
||||||
{
|
|
||||||
zassert_equal(dev, exp_dev, NULL);
|
|
||||||
zassert_equal(status, 0, NULL);
|
|
||||||
zassert_equal(*state, exp_state, NULL);
|
|
||||||
zassert_equal(arg, exp_arg, NULL);
|
|
||||||
callback_cnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void state_set(const struct device *dev, enum pm_device_state state,
|
static void state_set(const struct device *dev, enum pm_device_state state,
|
||||||
int exp_err, bool cb)
|
int exp_err)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
enum pm_device_state prev_state;
|
enum pm_device_state prev_state;
|
||||||
|
@ -145,19 +130,8 @@ static void state_set(const struct device *dev, enum pm_device_state state,
|
||||||
err = pm_device_state_get(dev, &prev_state);
|
err = pm_device_state_get(dev, &prev_state);
|
||||||
zassert_equal(err, 0, "Unexpected err: %d", err);
|
zassert_equal(err, 0, "Unexpected err: %d", err);
|
||||||
|
|
||||||
if (cb) {
|
err = pm_device_state_set(dev, state);
|
||||||
callback_cnt = 0;
|
zassert_equal(err, exp_err, "Unexpected err: %d", err);
|
||||||
exp_dev = dev;
|
|
||||||
exp_arg = &state;
|
|
||||||
exp_state = state;
|
|
||||||
|
|
||||||
err = pm_device_state_set(dev, state, pm_callback, exp_arg);
|
|
||||||
zassert_equal(err, exp_err, "Unexpected err: %d", err);
|
|
||||||
zassert_equal(callback_cnt, 1, NULL);
|
|
||||||
} else {
|
|
||||||
err = pm_device_state_set(dev, state, NULL, NULL);
|
|
||||||
zassert_equal(err, exp_err, "Unexpected err: %d", err);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum pm_device_state exp_state = err == 0 ? state : prev_state;
|
enum pm_device_state exp_state = err == 0 ? state : prev_state;
|
||||||
|
|
||||||
|
@ -174,16 +148,16 @@ static void test_uart_pm_in_idle(void)
|
||||||
state_verify(dev, PM_DEVICE_STATE_ACTIVE);
|
state_verify(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0, false);
|
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||||
communication_verify(dev, false);
|
communication_verify(dev, false);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0, false);
|
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0, true);
|
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||||
communication_verify(dev, false);
|
communication_verify(dev, false);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0, true);
|
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,21 +171,21 @@ static void test_uart_pm_poll_tx(void)
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
|
|
||||||
uart_poll_out(dev, 'a');
|
uart_poll_out(dev, 'a');
|
||||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0, false);
|
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||||
|
|
||||||
communication_verify(dev, false);
|
communication_verify(dev, false);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0, false);
|
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||||
|
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
|
|
||||||
/* Now same thing but with callback */
|
/* Now same thing but with callback */
|
||||||
uart_poll_out(dev, 'a');
|
uart_poll_out(dev, 'a');
|
||||||
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0, true);
|
state_set(dev, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||||
|
|
||||||
communication_verify(dev, false);
|
communication_verify(dev, false);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0, true);
|
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||||
|
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +194,7 @@ static void timeout(struct k_timer *timer)
|
||||||
{
|
{
|
||||||
const struct device *uart = k_timer_user_data_get(timer);
|
const struct device *uart = k_timer_user_data_get(timer);
|
||||||
|
|
||||||
state_set(uart, PM_DEVICE_STATE_LOW_POWER, 0, false);
|
state_set(uart, PM_DEVICE_STATE_LOW_POWER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static K_TIMER_DEFINE(pm_timer, timeout, NULL);
|
static K_TIMER_DEFINE(pm_timer, timeout, NULL);
|
||||||
|
@ -247,7 +221,7 @@ static void test_uart_pm_poll_tx_interrupted(void)
|
||||||
|
|
||||||
k_timer_status_sync(&pm_timer);
|
k_timer_status_sync(&pm_timer);
|
||||||
|
|
||||||
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0, false);
|
state_set(dev, PM_DEVICE_STATE_ACTIVE, 0);
|
||||||
|
|
||||||
communication_verify(dev, true);
|
communication_verify(dev, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ void test_dummy_device_pm(void)
|
||||||
test_build_suspend_device_list();
|
test_build_suspend_device_list();
|
||||||
|
|
||||||
/* Set device state to PM_DEVICE_STATE_ACTIVE */
|
/* Set device state to PM_DEVICE_STATE_ACTIVE */
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
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();
|
||||||
|
@ -334,8 +334,7 @@ void test_dummy_device_pm(void)
|
||||||
"Error power status");
|
"Error power status");
|
||||||
|
|
||||||
/* Set device state to PM_DEVICE_STATE_FORCE_SUSPEND */
|
/* Set device state to PM_DEVICE_STATE_FORCE_SUSPEND */
|
||||||
ret = pm_device_state_set(dev,
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_FORCE_SUSPEND);
|
||||||
PM_DEVICE_STATE_FORCE_SUSPEND, NULL, NULL);
|
|
||||||
|
|
||||||
zassert_true((ret == 0), "Unable to force suspend device");
|
zassert_true((ret == 0), "Unable to force suspend device");
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ struct fake_dev_context {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
struct fake_dev_context *ctx = dev->data;
|
struct fake_dev_context *ctx = dev->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -147,13 +146,13 @@ void test_pm(void)
|
||||||
*/
|
*/
|
||||||
k_yield();
|
k_yield();
|
||||||
|
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND, NULL, NULL);
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND);
|
||||||
zassert_true(ret == 0, "Could not set state");
|
zassert_true(ret == 0, "Could not set state");
|
||||||
|
|
||||||
zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
|
zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
|
||||||
|
|
||||||
/* Let's try to suspend it again, it should fail relevantly */
|
/* Let's try to suspend it again, it should fail relevantly */
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND, NULL, NULL);
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_SUSPEND);
|
||||||
zassert_true(ret == -EALREADY, "Could change state");
|
zassert_true(ret == -EALREADY, "Could change state");
|
||||||
|
|
||||||
zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
|
zassert_true(net_if_is_suspended(iface), "net iface is not suspended");
|
||||||
|
@ -163,12 +162,12 @@ void test_pm(void)
|
||||||
(struct sockaddr *)&addr4, sizeof(struct sockaddr_in));
|
(struct sockaddr *)&addr4, sizeof(struct sockaddr_in));
|
||||||
zassert_true(ret < 0, "Could send data");
|
zassert_true(ret < 0, "Could send data");
|
||||||
|
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
zassert_true(ret == 0, "Could not set state");
|
zassert_true(ret == 0, "Could not set state");
|
||||||
|
|
||||||
zassert_false(net_if_is_suspended(iface), "net iface is suspended");
|
zassert_false(net_if_is_suspended(iface), "net iface is suspended");
|
||||||
|
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL);
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
zassert_true(ret == -EALREADY, "Could change state");
|
zassert_true(ret == -EALREADY, "Could change state");
|
||||||
|
|
||||||
/* Let's send some data, it should go through */
|
/* Let's send some data, it should go through */
|
||||||
|
|
|
@ -55,7 +55,7 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_device_pm_ctrl(const struct device *dev,
|
static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb, void *arg)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_device_pm_ctrl(const struct device *dev,
|
static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state, pm_device_cb cb,
|
enum pm_device_state *state)
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue