2018-10-29 19:46:54 +08:00
|
|
|
/*
|
2019-01-02 20:39:25 +08:00
|
|
|
* Copyright (c) 2017 Intel Corporation.
|
2018-10-29 19:46:54 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
#include <zephyr.h>
|
2019-06-26 00:26:13 +08:00
|
|
|
#include <power/power.h>
|
2019-09-19 19:25:18 +08:00
|
|
|
#include <hal/nrf_power.h>
|
2018-10-29 19:46:54 +08:00
|
|
|
|
2019-01-02 20:39:25 +08:00
|
|
|
#include <logging/log.h>
|
|
|
|
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
|
|
|
|
|
|
|
|
/* Invoke Low Power/System Off specific Tasks */
|
|
|
|
void sys_set_power_state(enum power_states state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
2019-02-12 18:07:20 +08:00
|
|
|
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
|
2019-03-17 03:55:56 +08:00
|
|
|
#ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1
|
2019-02-04 22:30:57 +08:00
|
|
|
case SYS_POWER_STATE_DEEP_SLEEP_1:
|
2019-01-02 20:39:25 +08:00
|
|
|
nrf_power_system_off();
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
default:
|
2019-06-04 16:13:03 +08:00
|
|
|
LOG_DBG("Unsupported power state %u", state);
|
2019-01-02 20:39:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle SOC specific activity after Low Power Mode Exit */
|
2019-03-05 16:15:17 +08:00
|
|
|
void _sys_pm_power_state_exit_post_ops(enum power_states state)
|
2019-01-02 20:39:25 +08:00
|
|
|
{
|
|
|
|
switch (state) {
|
2019-02-12 18:07:20 +08:00
|
|
|
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
|
2019-03-17 03:55:56 +08:00
|
|
|
#ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1
|
2019-02-04 22:30:57 +08:00
|
|
|
case SYS_POWER_STATE_DEEP_SLEEP_1:
|
2019-01-02 20:39:25 +08:00
|
|
|
/* Nothing to do. */
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
default:
|
2019-06-04 16:13:03 +08:00
|
|
|
LOG_DBG("Unsupported power state %u", state);
|
2019-01-02 20:39:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* System is now in active mode. Reenable interrupts which were disabled
|
|
|
|
* when OS started idling code.
|
|
|
|
*/
|
|
|
|
irq_unlock(0);
|
|
|
|
}
|